Broadcasting Messages to All Clients
Learn about broadcasting messages to all clients (.Net client, JavaScript client).
Overview
We've already broadcasted SignalR messages to all the connected clients. This was achieved by making the call on the Clients.All
property in the server-side hub. But this way of broadcasting a message has its limitations. What if we want to exclude the client that has sent the message from the list of its recipients?
In SignalR, this can be achieved by using Clients.Others
instead of Clients.All
. And this is what we will now implement.
Open the LearningHub.cs
file in our SignalRServer
project and add the following method to the class:
Get hands-on with 1400+ tech skills courses.