Wasim
Wasim

Reputation: 1935

Creating the same SignalR Hub for all the clients

I'm just start testing SignalR for monitoring application . I have a control which make a call to the Hub by the client side. I noticed , each time the client make Connection.Hub.Start() it creates a new Hub instance in the server , I need to refresh my control all the time , so I don't want it to create new Hub for each one.

Is there a way to create single Hub for all clients or I'm missing something?

Upvotes: 13

Views: 5561

Answers (1)

Drew Marsh
Drew Marsh

Reputation: 33379

A Hub instance is created for each request, much like an ASP.NET Page instance is created for each request in WebForms, a Controller is created for each request in ASP.NET MVC or a WCF service instance is created for each service request when using InstanceMode.PerCall.

If you want to maintain shared state between Hub requests/instances you would need to use a static field or some other, more advanced form of state sharing (e.g. dependency injected singleton).

Upvotes: 20

Related Questions