Thursday, September 19, 2013

ASP.NET SignalR

ASP.NET SignalR is a library that allows developers to add real-time web functionality to applications quickly and easily. The library wraps various techniques and creates a unified toolkit for server to client push notifications. SignalR will leverage the best technique for bi-directional communication available for the current browser and server by first attempting to connect via WebSockets and then falling through to long polling. The best part is that your application code stays the same no matter what communication methodology is in use. SignalR also provides a very simple, high-level API for doing server to client RPC (call JavaScript functions in your clients' browsers from server-side .NET code) in your ASP.NET application, as well as adding useful hooks for connection management, e.g. connect/disconnect events, grouping connections, authorization.

SignalR can be used to add any sort of "real-time" web functionality to your ASP.NET application. While chat is often used as an example, you can do a whole lot more. Any time a user refreshes a web page to see new data, or the page implements Ajax long polling to retrieve new data, is candidate for using SignalR. It also enables completely new types of applications, that require high frequency updates from the server, e.g. real-time gaming. For a great example of this, see the ShootR game

Get it on NuGet by running:
Install-Package Microsoft.AspNet.SignalR


Get a sample on NuGet, straight into your app by running:
Install-Package Microsoft.AspNet.SignalR.Sample

4 comments: