Creating Real Time Connected Rich Internet Applications with Websockets

by - Friday, August 9, 2013

When considering how to deliver a solution to a Rich Internet Application (RIA) technology problem one considers the technologies available to the developer. 

This could be consideration between native technology toolsets available within mobile (iPhone, Android, Blackberry 10 and Windows Phone 8) and desktop (Windows and Linux) Applications compared with a technology agnostic solution built with HTML5, CSS3 and JavaScript.

One such problem encountered by Sumac was how to create a RIA that could push content and user interface changes to connected clients in real time. The key issue was the real time communication component. Web applications normally operate using HTTP protocols with some form of representational state transfer or REST involved however HTTP relies on a request-response model of communication where by a client makes a request and a server delivers a response.

For real time communication HTTP doesn’t really cut-it as the only way to deliver a near real-time experience is by client applications continuously polling a server for changes which is expensive and inefficient.

What is needed is push notification style of application whereby a client is always connected and communication is always open. As stated the HTTP cannot deliver this so what can?

Network sockets can provide the duplex, always on connectivity required and can do so in an efficient manner with far less overhead when compared to HTTP but support for network sockets but technology support can be limited, certainly in the case of HTML5 which leaves only native frameworks.

HTML5 and Javascript do have Websockets, a technology similar to network sockets except that message streams are exchanged between the server and client instead of binary streams whilst still maintaining all of the efficient connectivity benefits. Again however technology support was an issue. In a Microsoft technology stack support for Websockets in Windows 7 & Windows Server 2008 IIS7 just wasn’t there.

With the advent of Windows 8 & Windows Server 2012 IIS 8 Websocket support becomes possible and technology choices outside of a Microsoft stack becomes far less of an issue. Together with Microsoft’s Web and SignalR APIs we can provide easy Websocket support with Windows 8 & Windows Server 2012 without having to make complex technology choices.

We built an example Websockets prototype demonstrating the combination of these technologies and is available on our Microsoft Windows Azure hosted lab area, here: (http://sumac-lab1.azurewebsites.net/index.html)

Simply open two browser windows* of the same page and drag the pink menu bar across the page. See how the menu bar replicates instatly across each browser window.

*Note: Be sure to view the prototype in either IE9+, Chrome latest, Safari 6+ or Firefox latest to ensure Websocket support.

References:

- The SignalR website (http://signalr.net/) contains a number of useful walkthroughs on how to provide Websocket support within your RIA solution.

Send us a comment on this article