Adding real-time communication simplified with ASP.NET SIGNALR

As a developer I have seen how the world of web pages has evolved. Static web pages are long gone and dynamic web pages are expected even from the simplest of websites. But what do dynamic websites have to do with SignalR?  The official description says that SignalR is a library that can be used with any ASP.NET application to add real-time communication.  What exactly does it mean?  I had no idea and it is only recently that I have understood SignalR’s real meaning and value.

To put it in technical terms, SignalR is ASP.NET‘s new Library for the developer to develop real-time web application easily. It allows for bi-directional communication between Server and Client. So now a server can push the data content to the clients instantly as and when it becomes available.   SignalR is an abstraction over the WebSocket transport. WebSocket is a very powerful and efficient system for sending the messages between client and servers. WebSocket Is difficult to use directly, as it requires a lot of code to implement. SignalR reduces this complexity by just using the few lines code.

To simplify, SignalR has the powerful ability to push content from the  server-side code to the connected clients as it happens, in real-time.  Using WebSockets, that enables bi-directional communication between the browser and server, SignalR offers real-time functionality to any ASP.NET application. It works great for chat, but another better example would be games which require high-frequency updates from the server, i.e. real time gaming.  To summarise,  SignalR uses the web sockets, a new API available in the HTML5 which enables bi-directional communication between client (Browser) and the server.

SignalR also provides a simple high-level API for creating server-to-client remote procedure calls (RPC) that call the JavaScript functions in the client’s Browser from the server side .net code.  The below diagram describes the same.

Significance of SignalR Significance of SignalR

How to get SignalR?

We can simply get the SignalR by using NuGet command, i.e. Install-Package Microsoft.AspNet.SignalR.  We can also get the sample applications from Install-Package Microsoft.AspNet.SignalR.Sample

Supported server operating systems:
The SignalR server component can be hosted in the following server or client operating systems. For SignalR to use WebSockets, Windows Server 2012 or Windows 8 is required (WebSocket can be used on Windows Azure Web Sites, as long as the site’s .NET framework version is set to 4.5, and Web Sockets is enabled in the site’s Configuration page).

  • Windows Server 201
  • Windows Server 2008 r2
  • Windows 8
  • Windows 7
  • Windows Azure

To summarise, with SignalR, we can instruct the server side method to make a call back to the client side functions instead of waiting for entire server side method to complete the execution. This is by far, SignalR’s greatest advantage. However it is a relatively new technology and, does not provide the security for authenticating users.

Author

  • Raghvendra Anantha

    Raghavendra works as a Tech Lead in Trigent Software. He has more than ten years of experience in Microsoft .NET technologies. He likes to spend time with his cute little daughter, play cricket and badminton, listen to music and watch movies.