-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslave.js
41 lines (32 loc) · 855 Bytes
/
slave.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
var io = require('socket.io-client'),
config = require('./config/config'),
socket = io.connect(config.socketio.client.uri)
;
var status = {
name : 'slave'
};
// Connected to master
socket.on('connect', function() {
console.log('Connection to '+config.socketio.client.uri+' established.');
// Send current status to the master
socket.emit('/status', status);
// Received a message to control LEDs
socket.on('/led', function(msg) {
console.log(msg);
});
});
socket.on('disconnect', function() {
console.log('disconnect');
});
socket.on('error', function(err) {
console.log(err);
});
socket.on('reconnect', function(count) {
console.log('reconnected', count);
});
socket.on('reconnecting', function(count) {
console.log('reconnecting', count);
});
socket.on('reconnect_error', function(err) {
console.log(err);
});