How would I implement COMET for my (Flash) browser-based game?
I am currently trying to write a browser-based game that allows multiple users to navigate in a 2D map. It's RPG based and requires COMET as a technique for two users appearing and interacting on one screen, should they happen to appear in the same frame.
Also, in the game, I am embedding the maps within the SWF file, but I'm using HTTP requests to get data from a local server when the player steps into some key zones that I've drawn out. I was thinking of using XMLSocket but was wondering if there was a library, or some kind of implementation other than XMLSocket that would help me push or broadcast info to multiple browsers.
(BTw I am relatively new to Flash and server-client interaction, been learning it for about 4 weeks...links are helpful!)
The only real solution is Long-Polling or Streaming...BlazeDS implements both.
- I've heard that BlazeDS and LiveCycle Data Services from Adobe support data pushing. While LCDS is commercial, the first one is open-source. I haven't used either of them, so can't say anything about performance or other aspects.
- Use of XMLSocket requires the user to open the corresponding port, which might be blocked by a firewall (sometimes corporate firewall, on which the user doesn't have any control). (this applies even to BlazeDS and LCDS I believe).
- You can try the good old URLLoader + URLRequest combination to poll the server at fixed intervals for updates. If you're planning to try long polling (withholding the response until something happens), bear in mind that flash times out url requests after 30 seconds.