我将信号器集线器托管在一个单独的域上,并通过我的主应用程序与集线器 Build 跨域连接 . 当用户登录主应用程序时, Build 信号器连接 . 现在,我遇到的问题是如何识别集线器内的连接用户 . 如果我的HUb在主应用程序中,那么我可以使用登录用户的UserContext并维护字典(来自MessengR应用程序的示例)并在Connect和Disconnect事件上更新它们 .

private static readonly ConcurrentDictionary<string, List<string>> _userConnections = new ConcurrentDictionary<string, List<string>>();
    private static readonly ConcurrentDictionary<string, string> _reverseLookup = new ConcurrentDictionary<string, string>();

但作为一个跨域连接,我没有UserContext,也没有办法知道该连接ID属于谁 . 我迷失在这里 . 是否可以在Connect()事件上从客户端传递查询字符串?我有一个令牌来识别我可以用来跟踪的用户 . 或者将用户链接到连接ID的其他方式 . 如果有人可以给我一些方向 . 谢谢!