Last post Oct 20, 2017 02:42 AM by Jean Sun
Oct 19, 2017 03:16 AM|tadbirgaran|LINK
In the signalr, for each tag that opens, the ConnectionId registers for the user.
I use the following code to send messages to users. 1 2
hubContext.Clients.Clients (user.ConnectionIds.ToLi st ()); receiveNotification (message, userID, link);
The problem I have is that I want to send a message to the user once, not to the number of ConnectionId.
How can I find one of its active ConnectionIds and just send that message?
Is there a better way?
I also worked on this link
But because of I do not use request.User.Identity.Name, this method does not work. I'm using my user id. I'm reading the table. value of request.User.Identity.Name in my app is empty because i'm reading user information from table in database
Thanks for your advice
Oct 20, 2017 02:42 AM|Jean Sun|LINK
The IUserID provide allows users to specify what the userid is based on. By default, there will be an implementation that uses the user's
IPrincipal.Identity.Name as the user name. To change this, register your implementation of
IUserIdProvider with the global host when your application starts.
GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => new MyIdProvider());
For more about this, please take the following link as reference.