-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
49 lines (38 loc) · 1.14 KB
/
index.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
//
// Socket.IO plugin for Status Dashboard
//
// Christophe Hamerling <[email protected]>
//
var io = require("socket.io-client");
module.exports = function(statusdb) {
console.log("Init status dashboard Socket.IO client plugin");
var api = statusdb.api;
var settings = statusdb.settings;
var url = 'http://localhost:3303';
if (settings.plugins.socketio) {
url = settings.plugins.socketio.url || url;
}
var socket = io.connect(url);
socket.on('connect', function() {
console.log('Connected!');
});
socket.on('connecting', function(transport) {
console.log('Trying to connect with ' + transport + ' transport...');
});
socket.on('disconnect', function() {
console.log('Socket has been disconnected');
});
socket.on('connect_failed', function() {
console.log('Connection failed/timeout!');
});
socket.on('error', function(err) {
console.log('Error: ' + err);
});
// this is where we send stuff to the socket.IO server
api.on('refresh', function(status) {
socket.emit('refresh', status);
});
api.on('status', function(status) {
socket.emit('status', status);
});
}