Tuesday, 8 January 2019

Socket.io : emite out of on.connection

Hi guys!I'm starting to integrate Socket.io in my Nodejs backend, and I was wondering how you could emit from outside this part of the code :​io.on("connection", (client) => { }); ​I can do it from here, but I need to do it elsewhere.​Like If I get an api call in my backend from another user, I want to emite to all other client connected with websocket.​I presume I can do it with a looping function and flags, but I hope there is a better way?​Thank you!

Submitted January 08, 2019 at 07:35PM by Kardiamond

No comments:

Post a Comment