|
|
@ -4,17 +4,17 @@ var http = require('http').Server(app); |
|
|
|
var io = require('socket.io')(http); |
|
|
|
|
|
|
|
|
|
|
|
app.get('/', (req, res) => { |
|
|
|
res.send('<h1>Hello world!</h1>'); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
io.on('connection', s => { |
|
|
|
console.error('socket connection'); |
|
|
|
|
|
|
|
s.on('log', (data, room) => { |
|
|
|
s.to('iot').emit('message', data); |
|
|
|
console.log('broadcast', data); |
|
|
|
|
|
|
|
}); |
|
|
|
//s.emit('message', 'message from server');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|