✅ [SignalR] How to effeciently keep track of ConnectionIds.
I'm currently trying to build a little chat room where users can send messages. The thing I can't get over my head is if this is the best way to keep track of connection Ids. Since there could be multiple tabs open i want to send the message to all the tabs so I need to make a persistant layer where I associate an id and username with the connection Id of signalR. On the client side as soon as i connect to the websocket server i call the RegisterUser
3 Replies
you can do in-memory storage or DB persistence
the DB approach is required if you're running multiple servers
each approach is documented
If you want to track all connections (a single user may be opening more than one tab), you just have to make your user the key, and the value a list of connections; this is an example
Thanks