kzfabi
kzfabi

Reputation: 2075

Multiple SignalR hubs with different configurations

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

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?

Upvotes: 1

Views: 1077

Answers (1)

N. Taylor Mullen
N. Taylor Mullen

Reputation: 18301

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
});

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.

Upvotes: 6

Related Questions