This project is read-only.


For you to simply download the code & hit F5, there are couple of things that need to be installed:

  • Windows Phone 7.1 SDK .. get it HERE.
  • ASP.NET MVC 3 Templates & runtime .. get it HERE.
  • Latest Windows Azure Developer SDK (available HERE). This is not technically a requirement; but rather a nice to have for hosting the SignalR backend server. The web application can be hosted anywhere and the project solution will work fine without the Azure wrapper. 

Project Solution Structure:

Once you download the source code & launch the VS Solution, you should see a solution structure like this:

So, we are essentially seeing 3 projects .. let's break them down:

WP7SignalRHelperServer: This is a regular ASP.NET MVC 3 web application; but is houses the SignalR Hubs & the logic to communicate appropriately with connected clients. So, this is your SignalR backend server.

WP7SignalRHelper: This is a Windows Azure wrapper over the WP7SignalRHelperServer web application, so that the SignalR backend can be hosted as a Web Role in Azure with just two clicks. In reality, this is completely optional and only there for convenience. The WP7SignalRServer is a stand-alone MVC 3 application by itself and it can be hosted on any server with IIS & MVC 3 runtime.

WP7SignalRHelperClient: This is the companion Windows Phone application demonstrating real-time interactivity with the SignalR Hubs. The server & the Windows Phone app work seamlessly to have 4 types of connectivity stubbed-out. Your Windows Phone application could start here, or feel free to rip out any parts of this to inject into your existing application. The SignalR communication is wrapped into a Messaging Hub with interfaces & virtual methods for extensibility.

We dig into the individual projects below ...

The SignalR Server

This, as mentioned, is in the form of an MVC 3 web application built with standard templates. Accordingly, the project structure below shows the traditional setup of an MVC project. All the views are off of the Home controller and the usual ASP.NET membership providers have been preserved, if someone needs to use them.

What's new in the project is that the SignalR NuGet has been added to it, which includes some JS files & the DLLs. And then we have defined a bunch of custom SignalR Hubs to facilitate real-time communication with clients. Peek into each hub to see what we're doing .. should be self-explanatory. Most of the hubs deal with a class called PhoneClients to identify connected phones and maintain a local running list of clients, which may be persisted. Each of the Views reference SignalR JS scripts and offer UI appropriate to the function, mostly basic HTML/CSS & JS. The web front ends do open connections to the SignalR Hubs so that interaction from connected phones may be captured on the website.

 The Windows Phone Client

The Windows Phone application is a demo application which showcases using all the different Hubs in our SignalR server .. the point is to use this as a start or rip out the particular usage your app needs to have. While generic Windows Phone page templates are in use, the one addition is the SignalR WP7 Client NuGet, so that we can have SignalR connectivity natively. The project structure is as below:

The Windows Phone client has XAML pages/views to demonstrate connectivity with each of the SignalR Hubs - Maps, Chat, Game Score & Object Sync. All communication with the Hubs occur through a central class called the SignalRMessagingHub, which implements a generic interface, as described below:


    // Custom delegate.
    public delegate void SignalRServerHandler(object sender, SignalREventArgs e);

    public interface ISignalRHub
        // Custom event to act on when something happens on SignalR Server.
        event SignalRServerHandler SignalRServerNotification;       

        // Operations on SignalR server.
        void MapIt (MapClient phoneToMap);
        void UnMapIt (MapClient phoneToUnmap);

        void JoinChat (ChatClient phoneChatMessage);
        void Chat (ChatClient phoneChatMessage);
        void LeaveChat (ChatClient phoneChatMessage);

        void FollowLiveGame(GameScoreClient gameFollowingPhone);

        void StartObjectSync(ObjectSyncClient objSyncFromPhone);
        void DoObjectSync(ObjectSyncClient objSyncFromPhone);


All the SignalR messaging calls are implemented through virtual methods, which can be overridden for extensibility. Return communication from the SignalR Hubs, in response to events on the server, is handled through a custom event/delegate system. Custom eventargs capture information from the SignalR server and events bubble up to the Windows Phone views, without having to have hard reference to types on the XAML pages. All communication is asynchronous through the use of background threads so that the Windows Phone application UI remains responsive at all times.

So, c'mon .. give it a spin :) I would love some feedback so I may improve the libraries.

Questions / Concerns / Suggestions ?

Please add comments in the Discussions or ping me on Twitter (@samidip).


Last edited May 27, 2012 at 11:25 PM by samidip, version 22


uxadditives Jun 1, 2012 at 3:11 PM 
Thanks a lot! This looks very interesting.