Types of Clients in SignalR
SignalR
8 Articles
In this article, let's learn about types of SignalR clients.
Note: If you have not done so already, I recommend you read the article on Fundamentals of SignalR in .NET.
Table of Contents
Introduction
In our previous article we learnt the fundamentals of SignalR. Today in this article lets dive deep into the server and client features available in SignalR in .NET. One among them is the types of clients available in SignalR.
SignalR will use WebSockets when it's available, and gracefully falls back on other technologies when it isn't, while your application code stays the same.
Connect from Everywhere
SignalR isn't just for browsers. Your clients can be all sorts of applications - desktop, web, or mobile, and they don't even have to match. Mix and match to your heart's content!
Plus, you're not limited to any specific tech stack. Whether it's React, Angular, WPF, .NET MAUI, or Blazor, they can all hop on the SignalR train. The only thing to watch for is having the right client libraries. Luckily, there are JavaScript, .NET, and Java libraries available, so as long as your app's using one of those, you're good to go.
Steps
- Add Microsoft.AspNetCore.SignalR.Client Nuget Package to Client.
- Create HubConnection.
- Configure Handler to be invoked.
- Start the HubConnection.
- Finally close it on Component Dispose.
Blazor Client
Code Sample - Creating and Configuring Blazor Client
Console Client
Code Sample - Creating and Configuring Console Client
Javascript Client
Code Sample - Creating and Configuring Javascript Client
Summary
In this article, we learnt about different types of SignalR clients. We also saw how to create a blazor client, console client, javascript client and connect to the SignalR hub. In the next article, we will learn about IHubContext and Caller in SignalR.