0

I know signal R maintain a different Context.ConnectionId for each tab, I was testing a scenario when someone don't close the tab and enter different credentials. How can I tackle this problem for the context id to remain the same. I have a dictionary object in which Context.ConnectionId is my key. Below is my code.

 private static readonly Dictionary<string, ConnectionManger> connectionManagerDictonary = new Dictionary<string, ConnectionManger>();

 public void Connect(string username, string password, string xmppDomain)
 {
     //check connection manager already exists or not 
     if (!connectionManagerDictonary.ContainsKey(Context.ConnectionId))
     {
         ConnectionManger connectionManager = new ConnectionManger();
         connectionManager.OpenXmppConnection(5222, false, xmppDomain, username, password);

         connectionManagerDictonary.Add(Context.ConnectionId, connectionManager);
     }
 }
xleon
  • 6,201
  • 3
  • 36
  • 52
bilal
  • 648
  • 8
  • 26
  • 1
    Do you mean that the user signed out and signed in again with different credentials? if yes, are you using a SPA? if yes, you can disconnect the hub and connect again, otherwise, the page will refresh and you will have a new connection id anyway – Haitham Shaddad Nov 01 '16 at 05:09
  • OK, I have solve this problem on onconnect and ondisconnect function of hub. – bilal Nov 01 '16 at 05:20
  • 1
    @bilal I suggest you answer your own question with the code solution and then mark it as correct answer – xleon Nov 01 '16 at 13:54

0 Answers0