Reputation: 3201
Let's say for example I've a button that displays alert
to all the users. When I click the button, all the connected clients will see the alert
.
And let's say this is done by calling a Server Method from client, which calls a function on Client
that show an alert.
For example:
public class DemoHub : Hub {
public void ShowAlert(String message) {
Clients.All.showAlertMessage(message);
}
}
This is a server method in hub, that calls the client function to show alert message.
My question is, does the alert will be shown to the current client too? I mean, if I click the button, do I see the alert myself in this case?
Note: the above scenario is not a real scenario, that is just a similar illustration of my issue as my current scenario is rather complex to explain.
Upvotes: 0
Views: 717
Reputation: 1444
To broadcast to ALL connections including the caller you would use
Clients.All.showAlertMessage(message);
To broadcast to ALL EXCEPT the caller you will want to use the method
Clients.Others.showAlertMessage(message);
Can find more documentation on this at http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server#callfromhub
This method above will broadcast to all connections except the current one which I believe is what you are looking for
Upvotes: 5