We now need to create the SignalR Hub. To do this, perform the following steps:
- Add a class to your project to handle the server-side of the chat. We'll call it Chat:
This will need to be a subclass of the SignalR Hub class. Make sure to add the using directive for Micosoft.AspNetCore.SignalR. Visual Studio's Quick Actions works well for this:
- Now add a Task method to the class to handle the sending of the messages:
public Task Send(string sender, string message) { return Clients.All.InvokeAsync("UpdateChat", sender, ...