I am working on Signal-R private messaging. I tried to use sessions but didn't do. I want to use user-ids from database instead of context.ConnectionId. How can i do this?
I suggest you use an IUserIdProvider
. The default one generates user names from the client's IPrincipal.Identity.Name
, but you can provide your own:
http://www.asp.net/signalr/overview/guide-to-the-api/mapping-users-to-connections#IUserIdProvider
This allows you to send messages using .User(userName)
instead of .Client(connectionId)
.
The article I linked to also provides a few alternatives such as single-user groups for messaging users without using their connection ID.