When SignalR made 8-10 connections at a time live chat doesn't work

后端 未结 2 1506
我在风中等你
我在风中等你 2021-01-07 06:49

I am developing live chat using SignalR. It is great library. But i coped with one problem that I cant resolve for some time. So problem in when signalR made 8-10 connection

2条回答
  •  终归单人心
    2021-01-07 07:14

    Found how to workaround:

    Rewrite connectionId, so in every tab you'd have the same sonnection id:

     public class MyConnectionFactory : IConnectionIdGenerator
        {
            public string GenerateConnectionId(IRequest request)
            {
                return MyUserManager.Instance.CurrentUserID.ToString();
            }
        }
    

    Add to global.asax:

    GlobalHost.DependencyResolver.Register(typeof(IConnectionIdGenerator), () => new MyConnectionFactory());
    

    And I managed to open as mach tabs, as I could. And all tabs get notifications.

    Hope, that helped.

提交回复
热议问题