'Possible to use SignalR in .net 6 service worker as a windows service?

I'm new to .NET 6 and trying to convert an ASP.NET (5) background service project included SignalR to .NET 6 service worker which will be hosted as a windows service.

This is what I'm trying to do:

IHost host = Host.CreateDefaultBuilder(args)
    .UseWindowsService()
    .ConfigureServices(services =>
    {
        services.AddHttpClient();

        services.AddHostedService<PBXWorkerService>();

        services.AddSignalR();
    })
    .Build();

await host.RunAsync();

Now it needs to add SignalR endpoint such as how it added in startup class in previous version.

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapHub<AsteriskHub>("/signalr");
    });

How do I map endpoints in Program.cs class without adding startup class?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source