angularsignalrcore-api

SignalR .Net Core Multiple Connection


Hello I have application backend is .NET Core and frontend is Angular 2+. I have one page that two people can both chat and see report in charts. I want to connect chart data and chat to backend with signalR. I can connected chat application. But how can I also make connection for chart datas? If there is any idea i will be so happy.


Solution

  • to add another hub, you just create the second hub class and add it on the startup like:

    public override void Configure(IApplicationBuilder app, HostConfiguration hostConfiguration, ILogger<Startup> logger)
    {
        base.Configure(app, hostConfiguration, logger);
    
        app.UseWebSockets();
    
        app.UseCors(CorsPolicy);
    
        app.UseSignalR(routes =>
        {
            routes.MapHub<ChatHub>("/chatHub");
            routes.MapHub<DataHub>("/dataHub");
        });
    }