socket.io.users_to_sid
This is a node js module for socket.io applications. This module finds and manages which socket is from who and visa versa. One user per person. User means: Unlimited (new) browser tabs/windows, but same machine. OR client can pass custom authorized id and have one user with it's sockets per group of different machines. Make use of the middleware.
Author
kataras
Contributers
god-eater
Installation
$ npm install socket.io.users_to_sid
[NPM] https://www.npmjs.com/package/socket.io.users_to_sid
Usage
var express = ;var app = ;var server = ;var socketUsers = ; socketUsers;// OR use your express session middleware var rootIo = server; //default '/' as namespace.var chatIo = rootIo; var rootUsers = socketUsersUsers; /* default '/' as namespace. Each namespace has IT's OWN users object list,but the Id of a user of any other namespace may has the same value if request comes from the same client-machine-user.This makes easy to keep a kind of synchronization between all users of all different namespaces. */ var chatUsers = socketUsersUsers; // rootIo;//IMPORTANT but no errors if you want to skip it for a io.of(namespace) that you don't want the socket.io.users' support. chatUsers; chatUsers; rootUsers; rootUsers; rootUsers; //You can still use the io.on events, but the execution is after connected and connection of the 'users' and 'chatUsers', no matter the order.rootIo;