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:
- In Solution Explorer, create a new folder called Hubs at the root level.
- 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 Hub class in SignalR. The base Hub class gives us the features we need to interact with clients.
- Let's override a...