Fire and wind come from the sky, from the gods of the sky.

Sunday, 28 February 2010

Recently I was flirting with the idea of creating an online game, but I got distracted by wondering how to make the back-end more flexible.

To communicate the state of the game to N connected clients I figured I needed some kind of server which would accept "join"/"quit" requests and then make changes available.

To that end I came up with the idea that a client would make requests via HTTP such as:

http://example.com/server/game/chess/join

This would regard the originating client as part of a new chess game, for example, and return a UID identifying the "game channel".

http://example.com/server/changes/1-2-3-4

This will retrieve a list of all events which had occurred in the game which had not already been sent.

(Here 1-2-3-4 is obviously the UID previously allocated.)

http://example.com/server/submit/1-2-3-4/move

This would submit the move "move" to the server.

After mulling this over for a while it seemed like a great reusable solution, I'd make an initial "join" request, then repeated polling with the allocated UID would allow game moves to be observed. All using JSON over HTTP as the transport.

It was only this morning that I realised I'd have saved a lot of time if I'd just proxied requests to a private IRC server, as the functionality is essentially the same.

Still I'm sure this pattern of "join"/"poll"/"quit" could be useful for a lot of dynamic websites, even in the non-gaming world. So although the idea was mostly shelved it was an interesting thing to have experimented with.

D'oh.

ObFilm: Conan The Barbarian

| 3 comments.

 

Comments On This Entry

[gravitar] Anders Jackson

Submitted at 00:56:27 on 1 march 2010

You should have a look at XMPP and the pub/sub implementation.
You can have good controll over who have access to the nodes (as user verification it is built into XMPP) and the trafic is crypted (also feature of XMPP) and you have instant access to changes, without killing web server with polls.

There is already some games web sites based on XMPP pub/sub. And also some work in RPC (web service like) based on XMPP. Yes, XMPP is much more than just Jabber ;)

You can even define your own extension and send that over same channel as all normal work.

[gravitar] Toby

Submitted at 01:53:59 on 1 march 2010

Came here to say what Anders said; in fact I am building a XMPP pubsub based application right now, and taking advantage of built in TLS, etc.

[author] Steve Kemp

Submitted at 18:13:20 on 1 march 2010

Now that you've (both) mentioned it I agree XMPP is even more suitable than even IRC.

As it is I've stopped experimenting on this topic, but the next time round, when I do think I have a use for it, I think it'd be sanest to use XMPP directly.

 

Comments are closed on posts which are more than ten days old.

Recent Posts

Recent Tags