There are already some good walkthroughs about this on the SignalR github site (https://github.com/SignalR/SignalR) so as a warm-up I suggest you take a look at those. Both the low-level API and high-level API are interesting. The main difference is the amount of control you have over the connection and message processing. In the low-level API you have full control over this including being able to override what happens when a client connects, processing of messages, and even disconnection of the client. With the high-level API you for-go this for a much simpler implementation, in this case simpler does not mean less powerful or useful. I think in most cases the high-level API (hubs) will be the right approach and will have plenty of flexibility for what we are trying to accomplish.
In this walk-through I am going to setup a simple application that allows a user action to notify all connected admins. To keep it short and simple this will be done using 2 different pages. Default.aspx will be the client, and Admin.aspx will be the admin page.
To start off we need to create a new web application project (we will use webforms). Once we have a clean project we will use NuGet to install the SignalR package (this actually installs 2 packages, the SignalR.Server package and the SignalR.JS package). Along with the NuGet package we will be using two difference aspx pages; default and admin.
Your project should look something like this.
Our next step is to create our Hub. We will do this in a Services folder within the web project. In this folder we are going to add a new class named “AdminHub”. The contents of this class mirror what you have probably seen already.
The next two methods we have are wiring up of buttons to fire some c# code. These are the methods we defined on the hub and again this is convention based. Camel Case in c# and lower Camel Case in JS. The last line just initiates the clients persistent connection to the hub.
All in all, this library is extremely useful in a wide variety of cases and it so simple to integrate with that there is really no reason to not start using it. It is still being actively worked on and is open-source. A working demo is also available at http://www.infinitelooping.com/demos/. Demo source code is available upon request.
Don’t forget to check-out SignalR on github (https://github.com/SignalR/SignalR)