I am using @microsoft/signal on client end and azure Signalr on server end.
I did called SendAsync() from other api but its not worked for me.
Startup.cs:
services.AddSignalR().AddAzureSignalR();
app.UseAzureSignalR(routes =>
{
routes.MapHub<MyHub>("/my");
});
ITypedHubClient.cs:
public interface ITypedHubClient
{
Task BroadcastMessage(string name, string message);
}
MyHub.cs:
public class MyHub: Hub<ITypedHubClient>
{
public void Send(string name, string message)
{
this.Clients.All.BroadcastMessage(name, message);
}
}
In Service(Other API service which is in different port than signalR client):
private readonly IHubContext<MyHub, ITypedHubClient> hubContext;
// After record will be updated
hubContext.Clients.All.BroadcastMessage("RefreshDetails", "test");
In javascript client:
var connection = new signalR.HubConnectionBuilder().withUrl("/my").withAutomaticReconnect().build();
connection.on("BroadcastMessage", function (params) {
//TODO
}