Worth learning Comet (reverse AJAX) techniques?

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Worth learning Comet (reverse AJAX) techniques?

Post by Jackolantern »

I had honestly never heard of Comet techniques until the other day. To those who have never heard of it, it is also called "reverse AJAX" (the name is not an acronym as far as I know; it is just a play on "AJAX" since "Comet" is another cleaning product). It allows the web server to push updates to the browser without the browser specifically asking for it. Obviously the implications of this for browser-based games are huge. You could have real PvP that notifies players as soon as they are attacked and forces a page reload to a battle screen. You could have true real-time chat where the client would only need to send user-initiated chats, and they get all chats from others automatically, without polling or similar bandwidth-wasting techniques. You could have a real-time map that shows the movement of other players, also without polling.

However, with webSockets on the horizon, it really makes me question whether it is worth investing in this technique for something as complex as a game. Obviously webSockets would almost completely nullify the usefulness of such odd techniques as "long-held HTTP requests" and other Comet strategies. But since it seems Microsoft is going to hold off on webSockets in IE9 until a more solid, official standard for them is released, it could be quite a while before this is a reality for public internet development.

So what do you think? Does anyone know anything further about IE9 support for webSockets?
The indelible lord of tl;dr
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by Chris »

You bet. There isn't anything better! Every use omegle? Look how fast it goes even with a few thousand users. All down to using comet techniques rather than constantly calling files from the server. I'm actually using reverse Ajax in my browser game. It's coming around December in Alpha.

And no I've been testing with IE9 and there's not much support. But there isn't much support for much Ajax yet either.

Edit: Just got my hands on a newer IE9. Yes! There's support :D.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by Chris »

Here's a chat I was working on. Didn't know I had it on my laptop. Thought I lost it with all my other stuff when my brother decided my computers hard drive needed to be formatted.

Here's a link:
http://chrishemmens.com/shoutbox/

You may notice the debug at the bottom.

How it works is, the client asks the server for a response. The server keeps checking the chat file if it's been updated. If it's been updated. The server sends to the client the new data. Then it all starts again.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by Chris »

Quick flowchart I put together
Image

Shows you basically how it works.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by Jackolantern »

Wow, thanks! I definitely think I am going to check in on this then. This could really help to streamline a game! Again, thanks for all the info!
The indelible lord of tl;dr
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by Chris »

K, I've been working with the chat script a bit more. And have found out that using GET instead of POST saves a lot of loading time. I'm going to tweak it even moar, to see how fast I can get it to go. Keep in mind this is running off a slow overused server.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by Jackolantern »

It worked for me just as fast as any other straight AJAX chatboxes I have ever seen.
The indelible lord of tl;dr
tomtefan
Posts: 46
Joined: Tue Jun 22, 2010 12:46 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by tomtefan »

Curious to see what kinda chat thingy your working on chris. :D

Iam looking for a chatbox / shoutbox for my game.
So i tried to enter your site chris, but it seems to be down ??

Iam not looking for anything fancy or such, just a little box where players can type stuff.
And is it not best to use a chat that only updates/refreshes when ever a player says anything,
rather than querying at say every 1 - 5 sec wich i have seen some uses.
dave3460
Posts: 117
Joined: Wed Jul 01, 2009 2:13 pm

Re: Worth learning Comet (reverse AJAX) techniques?

Post by dave3460 »

Hey chris may be pushing my luck but is it possible to see the js as well

cheers dave
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Worth learning Comet (reverse AJAX) techniques?

Post by Torniquet »

certainly sounds the way forward :D

got any links to decent tutorials on using said methods??
New Site Coming Soon! Stay tuned :D
Post Reply

Return to “Coding”