Browse Source

add example

master
zeus 4 years ago
parent
commit
7327c3e200
  1. 8
      install/usr/share/swarmlab.io/sec/project/courses/example-helloworld/app/server.js

8
install/usr/share/swarmlab.io/sec/project/courses/example-helloworld/app/server.js

@ -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');
});

Loading…
Cancel
Save