Sending Messages to Other Clients

Learn to send messages to the other client.

Overview

SignalR Hub has a property called Context. This property represents the context of the current connection and contains some metadata related to it. For example, if we are connecting as an authenticated user, we'll be able to get user information from this property.

One of the properties of Context is called ConnectionId. This is the property that contains an auto-generated string that represents a unique identifier of the current client connection. If we know a unique identifier of any specific client connection, we can send messages to specific clients.

Modifying SignalR Hub

We'll start by adding the following method to LearningHub class of the SignalRServer project:

Get hands-on with 1200+ tech skills courses.