👉🏼 Click here to Join I ❤️ .NET WhatsApp Channel to get 🔔 notified about new articles and other updates.
Send Notifications using IHubContext and Caller in SignalR

Send Notifications using IHubContext and Caller in SignalR

signalr

6 Articles

Improve

In this article, let's learn about IHubContext and Caller in SignalR.

Note: If you have not done so already, I recommend you read the article on Types of Clients in SignalR.

Table of Contents

  1. Introduction
  2. IHubContext and Caller
  3. Summary

Introduction

In our previous article we learnt the different types of clients in SignalR. Today in this article lets dive deep into the server and client features available in SignalR in .NET. One among them is the IHubContext and Caller available in SignalR.

IHubContext and Caller

The IHubContext interface, which is tailored to each hub, can be injected and then used to access the hub's client property. It's super handy to have IHubContext available in dependency injection because it means we can tap into it from anywhere in the app where the Hub class is hanging out. But there's a catch: The caller is only accessible within the hub itself, not through IHubContext.

Code Sample - IHubContext and Caller

This leaves us with no possibility to send any notifications to the Caller alone. But there's also the possibility to put clients in groups and then send messages to a specific group.

Summary

In this article, we learnt about IHubContext and Caller in SignalR. We also saw how to use IHubContext to access the hub's client property. In the next article, we will learn about Groups in SignalR.

👉🏼 Click here to Join I ❤️ .NET WhatsApp Channel to get 🔔 notified about new articles and other updates.
  • Signalr
  • IHubContext
  • Caller
  • Notifications