Members - Reputation: 209
Posted 29 March 2012 - 06:29 PM
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?
Members - Reputation: 209
Posted 30 March 2012 - 01:17 AM
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.
Moderators - Reputation: 5165
Posted 30 March 2012 - 11:35 AM
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.
Members - Reputation: 731
Posted 30 March 2012 - 12:26 PM
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.