mattstyles / koa-socket

Sugar for connecting socket.io to a koa instance
242 stars 50 forks source link

Sending Private messages #38

Open Nahasean94 opened 7 years ago

Nahasean94 commented 7 years ago

There is a broadcast method to send messages to all connected users...what if i want people to chat privately? How can i implement that?

perymimon commented 6 years ago

I found you can accessed to all sockets by io.socket.clients() And you can get the current socket from ctx

io.on('message',  (ctx, data) =>{
     ctx.socket.emit(..., data)
});

that is what I found by now. hop you can continue from there