I have 2 ASP.NET Core Razor web apps. Each app will be using SignalR to communicate with web app clients and mobile clients. Because of my intended use, I have setup both web apps as Hub and Client, where the Client is using the .NET SignalR Client. Each of the 2 web apps have the following:
static internal HubConnection Connection; // In the Startup class
public Startup(IConfiguration configuration)
{
Configuration = configuration;
Connection = new HubConnectionBuilder()
// Where the URL is for the OTHER web app
.WithUrl("https://localhost:44386/NotificationHub")
.Build();
}
Each project also has a NotificationHub class, derived from Hub, in the Hubs folder.
In the Startup ConfigureServices method in each app I have as the last statement:
services.AddSignalR();
In the Startup Configure method in each app I have the following immediately before the call to UseMvc:
app.UseSignalR(routes =>
{
routes.MapHub<NotificationHub>("/NotificationHub");
});
In each of the NotificationHub classes I have:
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
So, I am unsure how to initially connect from one Client to a Hub and I am also unsure if I am using the URL correctly.