Each time you send a request to the hub server, your request will have a different connection identifier, so I added a static hash table containing a username that does not change continuously, and a connection identifier for signal r, every time you connect , the connection identifier will be updated
$.connection.hub.start().done(function () { chat.server.registerConId($('#displayname').val()); });
and in server code:
public class ChatHub : Hub { private static Hashtable htUsers_ConIds = new Hashtable(20); public void registerConId(string userID) { if(htUsers_ConIds.ContainsKey(userID)) htUsers_ConIds[userID] = Context.ConnectionId; else htUsers_ConIds.Add(userID, Context.ConnectionId); } }
Nada N. Hantouli Aug 31 '14 at 12:24 2014-08-31 12:24
source share