a couple of weeks ago

ASP.NET Core SignalR Introduction

Introduction

ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to applications. Real-time web functionality is the ability to have server code push content to connected clients instantly as it becomes available, and not having the server wait for a client to ask for new data.

An obvious first example is a chat. But you can do tons of stuff with it: real-time collaboration, real-time dashboards and charts, scheduler jobs updates, real-time games.

SignalR provides a bridge between server and client. From server-side, it provides a simple API that we can use to call JavaScript functions on client-side from our server-side code. From client-side, it also provides API that we can use to invoke methods on server-side. Therefore, SignalR provides both server-side (NuGet package) library and client side library (npm package).

SignalR will use HTML5 WebSocket API and will try to keep persistent full-duplex communication channel that operates through a single socket. If the browser does not support WebSocket, it will fallback to using another transport like Server Sent Events or Long Polling.

With SignalR managing connections is quite easy. We can easily do tasks like grouping connections, reacting on connecting and disconnecting, broadcasting messages to all clients or a particular set of clients simultaneously.

Key things to remember about SignalR:

  • A connection between client and server is persistent.
  • Applications can scale out to thousands of clients using SQL Server or Redis.
  • It uses HTML5 WebSocket API transport when it is available, otherwise falls back to other transports
  • Provides Hubs that allows us to call client methods from server methods and vice versa

 

History

Since some people are confusing one for another, let’s just say that we have two implementations of SignalR:

Even tho you can use and play around with new SignalR now, the official preview should ship with ASP.NET Core 2.0 RTM, and official release should come with version 2.1 (end of the year?). There are ways to use old ASP.NET SignalR with ASP.NET Core but it is quite hackish, and of course, Microsoft will not offer support for it.

David Fowler and Damian Edwards are original authors of SignalR. Interestingly enough, it started as a side project of these two guys and turned into a full official framework, supported by Microsoft and it became part of ASP.NET family. Cool!

Coding on original SignalR started in 2011. You can find first commits dating back to late July of 2011. It became Microsoft.AspNet.SignalR in autumn of 2012 (October?). You can find first official talk at Build 2012 here.

The first talk that I could find on Channel 9 is February 2012 – link here. Anything you can find from David and Damian is indeed a great watch or read.

Their most recent talks on SignalR:

 

Enough of history, nostalgia and all the warm feelings lets see how we can start playing with new SignalR.

Follow up post – SignalR – Simple Chat.

    codingblast