Search code examples
signalrblazor-server-sideasp.net-core-8

When using Blzaor (8) Server app. Can i reuse the blazorhub to send live notifications to the client, or do i need to create a seperate signalR hub?


I have a ConcurrentDictionary that keeps some company wide info for the app, it prevents user from doing some tasks when other users are doing other task. It all works fine as the system just checks when the task is initiated to see if it can be done. But i would like to improve it with some notifications and enabling and disabling some parts of the system (live). Before Blazor, i did something like this using singnalR an hubs. But since Blazor Server is essentially using signalR already and there is a balzorhub registered in program.cs already. Can i use that somehow? Is there a specific best practice for this within Blazor with .net 8. Or is the expectation to just add hubs for this kind of notification? To be honest i can't find any info on it.


Solution

  • Based on my opinion, I don't suggest you bind this notification system inside the blazor web app, I suggest you could create a new hub for this notification, using the same hub is good for reduce the connection, but it will caused other issue like hard to debug the application and may reduce the blazor app's performance.

    Using the different hub inside the different application, which will make your app become more available, since if you have other app which also need using this hub, it could directly connect to that hub url instead of getting other blazor information which may caused other issue.

    More details about how to use SignalR inside the blazor, you could refer to this article.