Hybrid or Not to Hybrid?

SignalR - A Quick Overview & Demo

 
What are my options when my application requires real-time chat, or a live dashboard showing real-time updates, or I want to build an IoT application that must act on multiple  real-time postings from various devices.   These are all use cases for real-time communications and interactive applications across various domains.   These are also use cases for using a real-time communication library called SignalR.

There are currently 2 different versions of SignalR with respect to Microsoft. First is the ASP.NET Core SignalR (formally SignalR for ASP.NET) and the Azure managed service called, not surprisingly, "Azure SignalR Service".

We can easily deploy a web application that supports the ASP.NET Core SignalR backend and self-host SignalR.   This is the simplest and fastest way to deploy SignalR.   The walkthrough and link to sample code below demonstrates the self hosting technique of using SignalR in a .NET Core 6.0 MVC application.

You can find the code for this walkthrough at  https://github.com/sgerold/signalr_demo

1.   Create your sample MVC application (No Authentication required)..  No need to go into details here.

2.   Use NuGet to install the following packages...  "Microsoft.AspNetCore.SignalR"

3.  Create the SignalR Hub:

  • Add new folder named "Hubs"
  • Add new class name "TaskListHub.cs" in Hubs folder
  • Add following code to new class

 4.  Configure Bootstrap (Program.cs) 

 5.  Finally - Lets update index.cshtml

Executing the Demo

1. start the sample app and view in browser
2. Execute the app in multiple browser tabs
3. Enter task in one browser and view communication to all connected clients



Summary

Ultimately we would like to update web clients that are running across multiple platforms (Azure, Linux, Windows, Mobile, and macOS).   This is when we consider using the Azure SignalR Service.  Once configured,  the managed Azure service is connected to clients via the defined connection string.

SignalR helps to enable bi-directional communication between web browsers, server applications and mobile applications.  It is just another tool in my toolbox and I am always excited when I get the opportunity to use it.  We can build responsive and powerful applications when we combine SignalR and Azure.   Let me know if you have any questions and/or advise moving forward.   I will continue learning and passing it on.