Original Post
Any suggestions / best practices in regards to client architecture in a networked game?
Example:
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"
OR
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?
Example:
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"
OR
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?