-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
59 lines (39 loc) · 1.51 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// See faker to generate good data: https://www.npmjs.com/package/faker
var http = require('http');
var fs = require('fs');
var faker = require('faker');
// Chargement du fichier index.html affiché au client
var server = http.createServer();
// Chargement de socket.io
var io = require('socket.io').listen(server);
// Quand un client se connecte, on le note dans la console
io.sockets.on('connection', function (socket) {
console.log('Un dashboard est connecté !');
// in interval emit the monitoring report.
setInterval(function(){
var randomEmail = faker.internet.email();
var currentTime = new Date();
var randomNumb = faker.random.number({
'min': 25,
'max': 100
});
var data = {
current_time: currentTime,
number: randomNumb
};
socket.emit('data', data);
}, 1000);
// in interval emit the monitoring report.
setInterval(function(){
var randomNumb = faker.random.number({
'min': 0,
'max': 2
});
var data = {
auto: randomNumb
};
socket.emit('lights-auto', data);
}, 3000);
});
server.listen(8080);
// http://www.infoclimat.fr/public-api/gfs/json?_ll=48.85341,2.3488&_auth=CRNVQgR6U3FRfFJlUCYCKwBoVWAAdlN0Uy8KaQ9qXyJWPVU0BWVcOl4wWyZVegA2UH0EZ15lUGBQO1IqDnxTMgljVTkEb1M0UT5SN1B%2FAikALlU0ACBTdFM3CmUPfF89VjRVOAV4XD9eOFsnVWQAMFBmBHteflBpUDdSMA5mUzkJYlU5BGJTOVE%2FUi9QfwIzADVVZgA3U2JTZgprD2dfP1Y8VWQFZVw7XjhbJ1VgADVQZQRiXmlQaVA2UjQOfFMvCRNVQgR6U3FRfFJlUCYCKwBmVWsAaw%3D%3D&_c=495d1dfd6f22658a55672c61c508c554