-
Notifications
You must be signed in to change notification settings - Fork 2
/
frontend.js
43 lines (33 loc) · 981 Bytes
/
frontend.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
/**
Additional module to output reports in browser with websockets
Notice: More than one tasks with different frontends is unpredictable
*/
var events = require("events");
var util = require("util");
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var connected = false;
var logger = require('./logger');
var PORT = 3008;
var opened = false;
var Frontent = function () {
var self = this;
app.get('/', function(req, res){
res.sendFile(__dirname + '/web/index.html');
});
http.listen(PORT, function(){
logger.info("Charts: http://localhost:" + PORT);
});
io.on('connection', function(socket){
opened = true;
if (connected) return;
connected = true;
self.emit("connected");
});
this.on("data", function (data) {
io.emit('data', data);
});
};
util.inherits(Frontent, events.EventEmitter);
module.exports = new Frontent;