Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

Opinions on client architecture in client/server game

This topic is 2760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Any suggestions / best practices in regards to client architecture in a networked game?


Two server types, lobby/game.

The lobby handles:
- registration of new users
- retrieval of list of game servers
- retrieval of the users current game server

The game server handles
- registering to a game
- all gameplay

Flow for a new client and player:

Connect to lobby
1. register new user
2. retrieve servers

(user selects server)

Connect to game
1. Register to game
2. Game server sends gamestate
3. Game progresses

Now in the example above, we could drive it from the server, i.e.

1. Register new user -> server responds with server list + client state change to "select server"

(user selects server and client logs in to game server)

1. Client sends user credentials -> server responds by registering player, returning game state and request client state "in game"


It could be more flexible and less streamlined:

1. Client sends register, receives ok + server list.
2. Client determines that it should change to the "select server" state (it has a server list, and just registered)

(user selects server, client opens game server.

1. Client sends "join game" request
2. Server registers client and sends game state
3. Client determines it should go into the "in game" state, since it has game state and just did a join game request.

Contrived example perhaps, but the point is:
Should the server explicitly drive the state changes, or is there an informal protocol when the state should change?

When server drives state, problems may occur where the client has a more finely grained state than the server.
When the client drives state change, then a) the state changes become informal b) client might need to assemble lots of information to reconstruct what state it should be in.

Which choice leads to a simpler client architecture?

Share this post

Link to post
Share on other sites

The FAQ for the forum is full of just this thing!

Where? I don't see anything in particular on tradeoffs in client protocol design?

In-game is rather much simpler, since one tends to have an overarching game<->client synchronization mechanism there and we just keep an open socket and synchronize models.

The lobby/login design is a bit trickier, especially when it *almost* could be stateless (and the client basically just could use a chain of HTTP/HTTPS requests).

Stateless transfers is attractive in some ways since the client is going to run on cellphones as well. However, since the game needs a live open socket, this problem needs to be handled anyway. It's better to handle it uniformly I think.

Share this post

Link to post
Share on other sites
In general, it depends on the genre of game. RPGs typically end up having a different structure than FPSs. TBGs have a different structure than RTSs. Asynchronous games have a different structure than real-time head-to-head.

So, there is not "one single solution." For an RTS, you probably want to go "input synchronous." For an action game, that can work great, too, but you probably want to speculate forward for the player simulation, and accept corrections from the server. For an RPG, you probably want to worry more about replicating triggering events, rather than specific property changes. For a TBG, you typically want full states out, but perhaps only actions in. The list goes on -- the FAQ has a lot of links to different ways of doing this.

Share this post

Link to post
Share on other sites
If you look at examples like counter strike etc. there is not really a game state change for the first scenario you describe. You are polling the server list, get a response (or not) and then display the servers.

If the user then selects to join a server, you could switch to a loading state, where first a connection is established the game content is loaded, game state recieved, etc.

Then if everything is all right you switch to the ingame state.

I dont know why you would want the server to switch the game states of the client, does not make sense to me. In a finite state machine you switch the state automatically when you receive a certain input.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!