I'm attempting to build a windows service that's self-hosting SignalR.
I have read through tutorials such as SignalR Self-Host on ASP.Net
I'm noticing that, least it seems, that they're based around broadcasting messages, and can't seem to find anything around listening.
I need to listen to messages from within the service, as well as broadcast.
We already have our backplane setup - it's the same one that the site uses.
In a web site I can join a group, via Javascript. How do I join a group in a self-hosted SignalR service.
In a web site I register a callback on a hub. How do i register the same callback in a self-hosted service?
some example code that I have in place, for registering and starting SignalR is:
GlobalHost.DependencyResolver.UseSqlServer(Settings.Default.ISDBContext);
app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
HubConfiguration hubConfig = new HubConfiguration()
{
EnableDetailedErrors = true,
EnableJSONP = true,
};
map.RunSignalR(hubConfig);
});
I then start my webApp like this:
SignalR = WebApp.Start<Startup>(options);
options are the url's i'm registering. Startup is the startup class containing the signalR mapping above.
Little lost here as I haven't built a self-hosting service before
In general SignalR offers a real-time messaging environment with the benefit that it can push messages to clients without them requesting the update (you've read the intro, so enough for that). Whether you start your self-host from within a service shouldn't make a difference.
From what I understand from your scenario: You need to consume the messages from the self-hosted service. I think you might only need a hint to the SignalR Desktop Client. I think your app/service should start off the service and then act as a client to the service itself. This would be the cleanest approach.
As the javascript client it acts as a consumer of the service with the same capabilities:
and vice versa from the desktop client to the hub:
To work with groups, the logic needs to be defined within your hub. The documentation Working with groups gives an understandable overview.