[web] Server-push in a Javascript browser-based MOG

Started by
7 comments, last by GameDev.net 18 years, 2 months ago
Hi All, I've been doing various experiments and I think I can make this work. What I intend to do is create a prototype (very stupid game) to illustrate techniques for doing this. 1. The HTML side of things will consist entirely of static pages - no PHP generation etc, because it's simply not necessary 2. The gameplay will be managed entirely by client-side scripts (i.e. &#106avascript). The entire game is likely to run in the same HTML page. 3. Client-server communication will be by way of XMLHttpRequest - not necessarily in XML though. --- The game server will work as follows: 1. A central process (i.e. single-threaded) application will run on the server and keep track of the true game state. All events will be timestamped. 2. The XMLHttpRequest clients will go into some sort of gateway (PHP or something) which will just decode the parameters and send the information to the local server process. It could communicate with the server via a Unix socket or something similar (doesn't matter really). The normal request will be "Here are my local commands at time index T2, please send me everything which happened since time index T1" and the response will be "Here are the relevant parts of the game state at time index T3" There will be an additional command "Please send me the complete game state" which will be used only when a client first connects. -- I hope to have a close-to-realtime (very simple) game working soon. Comments please Mark
Advertisement
Quote:Original post by markr
Comments please

I don't see any real pushing going on. It's basically a polling client.
But that can work just fine for the appropiate type of game.

shmoove
Ahh I didn't explain it very well.

It is basically a polling client, but it doesn't poll in a continous fashion - rather the poll should wait until "something interesting" happens.

So if nothing very much is going on, the polling would be slower.

You can't really do true server-push very easily just using XMLHttpRequest, because if you wait indefinitely, it may time out. There may be an option to do proper server-push with XMLHttpRequest in Mozilla (I shall have to investigate that), but it will not work in other browsers.

Mark
And how does the client know when exactly "something interesting just happenned" and it's time to poll? That's the part I don't see in your description. Or does "something interesting" refer to stuff happenning on the client's side?

shmoove
No, the client is polling all the time.

This means that it's more or less constantly got a XMLHttpRequest "on the go". But it may take quite a long time to complete that request.

However, the server process handling the request will do the blocking until "something interesting happens". As far as the server is concerned, something interesting has happened, if it happened since the last successful update on the client (regardless of how long ago that was).

There should be a way of combining many events into one message, so that the client can "catch up".

---

I've just been reading about Mozilla's server push. This would be really useful, but it only works in Mozilla.

Mark
Oh, OK. That was the piece of the puzzle that was missing. Too bad this won't work on mobiles.

shmoove
Quote:Original post by markr
This would be really useful, but it only works in Mozilla.

No, it works in most modern browsers, just the syntax is a little different.
I believe it's sometimes called AJAX, and it's basically a mix of XML, DHTML and &#106avascript.
Some examples showing this technique can be found on these locations:
mrspeaker
openrico
Or see Google's Maps and GMail.

And yes, it is very useful :)
It works fast, but close-to-realtime might be a bit much to ask.
Quote:Original post by WanMaster
No, it works in most modern browsers, just the syntax is a little different.


No, it does not work in any non-Mozilla browser.

I'm not talking about XMLHttpRequest, I'm talking about doing server push through XMLHttpRequest. Read the page I linked for more info. This was originally a Netscape-specific protocol, and is still supported only by Mozilla.

Mark
Hmm..

Have you seen my Creative Object world (with an ajax front-end + old framesand even older no-frames)?

http://wolspace.com/cow

Its a text based multi-player virtual world:
create a small cat
paint it as pink
create a large wooden chair
put the cat on the chair
pose it as sleeping

Or maybe my new graphic game engine:

http://wolspace.com/josh

There is so much to do and only little old me doing it so if anyone is interested in lending me a coding hand, jus let me know.

wm AT wolispace DOT com

. ___
/\__\ wolispace.com/cow
\/__/ What is the wrold coming to?

This topic is closed to new replies.

Advertisement