With flash based games (or flex), is it a pull or request/response system or is it possible for the game server (say java based) to actually push out to its remote flash clients?

  • 1
    \$\begingroup\$ It depends on your method of communication. Are you using remoting/web requests or sockets? \$\endgroup\$ – Luis Estrada Feb 28 '12 at 22:56

There are basically two different ways you can achieve "pushed" updates through flash. Using the Socket class is the most straightforward and gives you the most control. At this level, you can either exchange XML data or just read and write raw bytes. The only real downside is that some people might have trouble connecting depending on things like routers, firewalls and security software. There's also a tricky little bit about setting up a security policy server, which isn't made immediately obvious in the Socket API documentation.

The second method is to use a long polling HTTP request via the URLStream class. Essentially the client will make a regular HTTP request that stays open, then the server will push data down that connection as it becomes available, and the URLStream class allows you to process the data as it comes in. If the client needs to send any updates to the server, it can do so through regular HTTP requests, the tricky part is to ensure that something in that request reliably identifies the client so the server can apply the update properly (and securely).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.