Overview

In the previous section, we learned to send SignalR messages to all the connected clients except the sender. Now, we'll do the opposite. We'll send messages only back to the sender. The built-in property on the Clients property of the Hub base class allows us to do this. It’s called Caller.

We would want to send a message only to the client that has triggered a particular method for many different reasons. For example, any scenario where the request-response messaging model is appropriate would utilize this functionality. Let’s now apply this ability to see it in action.

Enabling self-messages

To utilize the Caller property, we will follow the given steps:

Step 1: Add method to the LearningHub

We will add the following method to the LearningHub class of the SignalRServer project:

Get hands-on with 1400+ tech skills courses.