Reputation: 567
I started using the SignalR library recently and i have some doubts...
It's possible I send a message to specific user and in a specific View? For example: My user is connected in my system, but he have two or more screens open, but I need to send the message only to the view where the action occurred.
I intend to use this to display system notification messages (inclusion successfully, unexpected errors, etc.). It is a good alternative to use SignalR?
Thanks
Upvotes: 1
Views: 865
Reputation: 5312
As you probably know, SignalR allows for mapping users to connections and SignalR provides a connection id for each connection.
Each view would technically have its own connection. If you want to share a SignalR connection between views, you have to implement it yourself.
If you want to push system notifications realtime from the server to the client, then SignalR is a good choice.
Upvotes: 0
Reputation: 171
I believe each tab in the browser creates a separate signalR connection, so maybe you have to solve this problem first as there is a browser limitation of max number of connections. For this check out this project or even this.
Now when you have one connection for multiple opened tabs, you should test when a message is received from the server if a callback is executed in every tab. If yes then you can determine whether you are in the desired page (for example by checking for html elements) and do your thing and if not - do nothing.
Upvotes: 1