Signalr IConnectionIdGenerator在SignalR 1.0rc2发布未找到 [英] Signalr IConnectionIdGenerator not found in SignalR 1.0rc2 release

查看:507
本文介绍了Signalr IConnectionIdGenerator在SignalR 1.0rc2发布未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用来实现用下面的代码我自己的连接ID生成器:

I used to implement my own connection id generator with the following code:

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

这是工作的罚款与SignalR 0.5.3版本,但更新到SignalR 1.0rc2发布后的命名空间或类名未找到。另外,我无法找到这个重大更改任何音符这里 https://开头github.com/SignalR/SignalR/blob/master/ReleaseNotes.md 你能帮我解决这个问题?

This was working fine with SignalR 0.5.3 release but after updating to SignalR 1.0rc2 release the namespace or class name is not found. Also, I am not able to find any note on this breaking change here https://github.com/SignalR/SignalR/blob/master/ReleaseNotes.md Can you help me fixing this issue?

推荐答案

这的确是走了,还有,你应该做用户/连接手动映射现在没有直接的替代品。

This is gone indeed and there is no direct replacement as you're supposed to do the user/connection mapping manually now.

我解决它使用的是HubPipelineModule和设置。最多的一组该用户的所有连接

I solved it using a HubPipelineModule and setting up a group for all connections of that user.

public class AuthenticationHubPipelineModule : HubPipelineModule
{
    protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
    {
        var id = MyUserManager.Instance.CurrentUserID.ToString();

        context.Hub.Groups.Add(context.Hub.Context.ConnectionId, id);

        return base.OnBeforeIncoming(context);
    }
}

当你再想要伸手给用户,你可以将它发送给该组是这样的:

When you then want to reach out to the user, you can just send it to that group like this:

var context = GlobalHost.ConnectionManager.GetHubContext<YourHub>();
context.Clients.Group(userId).yourCallbackMethod();



希望这可以帮助,
伊夫

Hope this helps, Yves

这篇关于Signalr IConnectionIdGenerator在SignalR 1.0rc2发布未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆