Answer the question
In order to leave comments, you need to log in
Why is SignalR Core running in a service being ignored?
register service:
var provider = services.BuildServiceProvider();
using (var scope = provider.CreateScope())
{
IHubContext<CrashHub> crashHub = (IHubContext< CrashHub > )provider.GetService<IHubContext<CrashHub>>();
GamesContext сrashService = new GamesContext(connection);
services.AddSingleton<IHostedService, CrashService>(s => new CrashService(crashHub, сrashService, Configuration));
}
IHubContext<CrashHub> crashHub = (IHubContext< CrashHub > )provider.GetService<IHubContext<CrashHub>>();
is responsible for getting the hub context, then I pass it to my service. public CrashService(IHubContext<CrashHub> hubContext, GamesContext db, IConfiguration configuration)
{
_db = db;
_hubContext = hubContext;
}
await _hubContext.Clients.All.SendAsync("wait", 2);
, but it is not sent. What to do about it, what could be the reason?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question