I use express
, socket.io
.
I have two user types
site visitors (Site users)
admins (site admins)
When visitors visit the site, i add user data(browser, location, ip..etc..) to VisitorObject
and show the VisitorObject
to admins.
When admins want to send message to a visitor, i should emit function of only user which the admin wants to type.
I don't want to use
io.sockets.emit('newMessage', message);
I want to use like this
io.sockets[id].emit('newMessage', message);
EDIT---
i am connection node.js server with
var socket = io.connect('http://127.0.0.1:3000', {query: 'id=' + id});
This id is not a socket id, it is the user id. I don't want to use socket.id on send message. I want to use user id. Because socket.id always change for the tab of browser.