多SignalR集线器不同配置 [英] Multiple SignalR hubs with different configurations

查看:399
本文介绍了多SignalR集线器不同配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到一个情况我需要多个SignalR集线器(至少2)具有不同的配置。

I've run into a situation where I need multiple SignalR hubs (at least 2) with different configurations.

目前与V1.1.0我只能做这样的事情而​​配置所有集线器如下:

Currently with v1.1.0 I can only do things like the following which configures all hubs:

GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(30);

是否有可能为多个集线器设置不同的配置?

Is it possible to set different configurations for multiple hubs?

推荐答案

所有集线器共享相同的连接对象,因此他们都有着相同的配置。

All hubs share the same connection object therefore they all share the same configuration.

如果您想拥有一台服务器,但多个连接配置为集线器可以做到以下几点:

If you want to have 1 server but multiple connection configurations for hubs you can do the following:

app.MapHubs(yourPathToConnectionWithConfigurationA, new HubConfiguration
{
    Resolver = MyResolverWithConfigurationA
});

app.MapHubs(yourPathToConnectionWithConfigurationB, new HubConfiguration
{
    Resolver = MyResolverWithConfigurationB
});

因此​​,当你想使用一个配置连接到该服务器的终点,当你想连接到端点B连接到端点。请记住,集线器不会将客户/横跨两种配置的连接,即使枢纽将是两者兼而有之。

Therefore when you want to use configuration A you connect to that server end point and when you want to connect to endpoint B you connect to that endpoint. Keep in mind the hubs will not share clients/connections across the two configurations even though the hubs will be on both.

这篇关于多SignalR集线器不同配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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