Thursday, 14 April 2011


Something I always like about flash was the ability to push data from the server to the client for real-time communication.

For me the down side was it always required some server side technology like Red5 or BlazeDS, and I never had the time to get into Java to do anything too complicated.

Now there is a much better replacement with HTML5 and Websockets, you can push data from the server with a bit of C# and capture it with some simple Javascript.

Websockets aren’t supported by all browsers yet, but I think its quite a handy development, and there are quite a few c# libraries out there to get started.

I had a look at some of them:

They all seem pretty good and fairly easy to use but I had to start with one, Superwebsocket seemed to be the option for me.

One of my main problems with this kind of thing in Flash was it required a separate, standalone server running along side your website.  Superwebsocket’s gives you a few options, you can create a standalone server or you can integrate the code into an existing web project.

Its pretty easy to get started, once you include their DLL’s in your project, most of the code for dealing with client/server commands is included in the global.asax with a little configuration information in the web.config.
I created a fairly simple example here, most other demo’s are basic chatrooms, I thought I’d test to see if it would be feasible to use Websockets for a multiplayer game.

It’s a little jerky, I don’t know if it’s my coding or because I’m integrating the server code into the website, I’m going to try a standalone server version as well to see if it makes a difference.

No comments:

Post a Comment