Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 919
Wasim Avatar asked Jul 16 '12 12:07

Wasim


1 Answers

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).

like image 138
Drew Marsh Avatar answered Oct 12 '22 23:10

Drew Marsh