Quantcast
Channel: WP7SignalRHelper Wiki Rss Feed
Viewing all articles
Browse latest Browse all 20

Updated Wiki: Documentation

$
0
0

Pre-Requisites:

For you to simply download the code & hit F5, there are couple of things needed 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, DLLs & some config changes. 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. All the hubs deal with a base 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 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 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 theSignalRMessagingHub, which implements a generic interface, as described below:

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.

 


 

Questions / Concerns / Suggestions ?

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

Thanks!


Viewing all articles
Browse latest Browse all 20

Trending Articles