Reputation: 504
i created an array which contains our information about socket and sessions and nicknames like below
myarray == [
{sessionId: '12345', nickname: 'timmay!', socketIds: [1, 2, 3]},
{sessionId: '23456', nickname: 'pete', socketIds: [4, 5, 6]}
]
now i want to disconnect socket.id number 1 and 2 because i want a user just have 1 socket for 1 browser.
for example if user with nickname timmy open our chat with one tab of his browser we have socketIds: [1]
then if he open another tab we create another socket for him with id 2,now we have 2 id for one client.
is there anyway to disconnect id number 1 with socket.id?
some code like this for instance?
socket.disconnect(socket.id)
Upvotes: 2
Views: 522
Reputation: 2173
Try this:
delete io.sockets.sockets[myarray[index].sessionId];
Upvotes: 2