Creating a SignalR hub

In this section, we are going to implement what is called a SignalR hub in our ASP.NET core backend. A hub is a class on the server where we can interact with clients. We can choose to interact with a single client, all connected clients, or just a subset of them.

Let's open our backend project in Visual Studio and carry out the following steps:

  1. In Solution Explorer, create a new folder called Hubs at the root level.
  2. In the Hubs folder, create a new class file called QuestionsHub.cs that contains the following content:
using Microsoft.AspNetCore.SignalR;using System;using System.Threading.Tasks;namespace QandA.Hubs{    public class QuestionsHub: Hub    {            }}

Our class is called QuestionsHub and we inherit from the base ...

Get ASP.NET Core 3 and React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.