From the course: Learning SignalR with ASP.NET Core

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add a SignalR hub

Add a SignalR hub

From the course: Learning SignalR with ASP.NET Core

Start my 1-month free trial

Add a SignalR hub

- [Narrator] The most important part of the SignalR app is the hub. Let's build a hub by creating a new class. I'll right click, choose add class. I'm gonna call this Chat Hub, but you can name it whatever you want. This class needs to inherit from the Hub Class, which is available in the Microsoft.AspNetCore.SignalR package This package is available in Asp.NetCore projects by default. If it doesn't show up for you for some reason, go to the NuGet package manager and install it. Clients can call any public method defined on the hub class. In our application, clients need to send a chat message to the hub, so let's add a method called Send Message. Here in the hub I'll do public task send message. That's the name of the function that a client will invoke. We'll take a parameter called name and also a parameter called text. In this send message function I want to create a new object, I'll say var message equals new chat message, which is a model that I'll need to define. We'll just copy…

Contents