var path = require('path'); var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); /* // server side code io.sockets.on('connection', function(socket) { socket.on('create', function(room) { socket.join(room); }); }); */ io.on('connection', s => { s.on("iot", function (room) { s.join(room); console.error('hi'); s.to(room).emit('message', 'hi from server'); io.emit('iotdata', 'hi from server'); }); }); http.listen(8084, () => console.error('listening on http://localhost:8084/'));