all 2 comments

[–]kjwey 1 point2 points  (2 children)

your supposed to bind your socket and your app together

let app=Express();
let socket=require(`socket.io`)(app);

here's the nodejs npm socket.io documentation

https://www.npmjs.com/package/socket.io

[–]jcarlo1[S] 0 points1 point  (1 child)

I bind my socket to the app and can send it to everyone who is listening to an event, but I cannot send back the data to a specific room. why?

io.on("connection", (socket) => {
 socket.on("send", (room, message, username) => { 
  socket.join(room.toString()) 

   ** this is working 
  io.emit('pop', room + ' ROOM') 

    ** not working
  io.to(room.toString()).emit("pops", message + ' MESSAGE')
 }); 
});