we are implementing chat and other notifications by socket.io in node js project.
we need to keep user -> socket mapping.
For this we have declare global variable in app.js
global.user_sockets = {};
and assign userid, socket mapping in user_sockets array
user_sockets[data.userId]=socket;
For using global variable there are many speculations. some users say it will be not good when using with multiple process.
Any other solutions on this?
via jit
No comments:
Post a Comment