Reputation: 21128
When I implement a SignalR Server and Client in the same library, how to tell the server which hubs
to use?
My first try was:
public void Configuration(IAppBuilder app)
{
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
hubConfiguration.EnableJavaScriptProxies = false;
hubConfiguration.Resolver.Resolve<TeamHubServer>();
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(hubConfiguration);
}
It seems that all classes
that inherit from Hub
are registered.
Thanks a lot!
Upvotes: 0
Views: 206
Reputation: 297
You have to define a class that inherits from Hub
public class ExampleHub : Hub
then override this two methods
public override Task OnConnected()
public override Task OnDisconnected(bool stopCalled)
and you will be able to define new methods in the ExampleHub class
After all this you will call the method as following:
var con = GlobalHost.ConnectionManager.GetHubContext<ExampleHub>();
con.Clients.All.addNew(param);
Upvotes: 1