views:

151

answers:

1

Hi, I want to make an online flash game, it will have social features but the gameplay will be primarily single-player. For example, no two players will appear on the screen at once, the social interaction will be through asynchronous messages, there won't be real-time chat or anything. Much of the logic would happen in the client, the server would validate the client logic, but it wouldn't need to be totally synchronous, which is why I'm thinking polling might be satisfactory.

I have read in many places that socket servers can be more efficient than using polling for online games, but is that mainly a consideration for games that are more multi-player with more mult-player interactions than the game I have descriebed? If many users are playing online at the same time, but each playing a relatively isolated game, and not interacting to in real-time with each players, could polling be okay, or would using sockets be advisable no matter what if you have an online game that you envision many people playing at the same time? Thanks!

A: 

What kind of server do you have? Does it support persistent connections (i.e. can it run a loop on its own) or does it only support stateless mode (where your clients have to poll)?

Stateful

Multiplayer games like Quake / Half-life and so on are run on servers that keep persistent connections to the clients that connect. That is a lot more efficient because it can then keep the relevant game state in RAM memory instead of saving it to the disc/database after each message.

Stateless

If you have a web server (PHP for example) you are pretty much limited to stateless mode where you simply wait for a client message, load all relevant information from a database, do some calculations and then return an answer to the client. In this case you need to do all of this for each and every "transaction" (client poll).

If the communication is sparse and simple the stateless server might actually be a better choice. It is very easy to implement.

bitc