I have some problem with signalR, I can not send message to specific User From Hub.
I want to do like this:
public void Send(string userToId, string userForId, string message)
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<ChatHubs>();
//userForId - it is Session["UserId"]
context.Clients.User(userForId).updateMessages(message);
}
I have already read this topic: http://www.asp.net/signalr/overview/guide-to-the-api/mapping-users-to-connections , but It's not clear for me, because I have not this var name = Context.User.Identity.Name;
I have User information in Session Variable and second when I get connectionId like this: var myClientId = $.connection.hub.id;
connectionId -is changed when I refresh page or when I click another menu on my project.
I have some questions: 1) Can I send message to specific user without connectionId (use only session["UserId"]) ? 2) In General, How can I make easily one-to-one messaging with SignalR ?
P.S. I'm working ASP.NET MVC (C#)