Jump to content

  • Log In with Google      Sign In   
  • Create Account

Opinions on client architecture in client/server game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 lerno   Members   -  Reputation: 209

Like
0Likes
Like

Posted 29 March 2012 - 06:29 PM

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?

Sponsor:

#2 hplus0603   Moderators   -  Reputation: 5342

Like
0Likes
Like

Posted 29 March 2012 - 08:35 PM

The FAQ for the forum is full of just this thing!
enum Bool { True, False, FileNotFound };

#3 lerno   Members   -  Reputation: 209

Like
0Likes
Like

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.

#4 hplus0603   Moderators   -  Reputation: 5342

Like
0Likes
Like

Posted 30 March 2012 - 11:35 AM

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.
enum Bool { True, False, FileNotFound };

#5 Inferiarum   Members   -  Reputation: 733

Like
0Likes
Like

Posted 30 March 2012 - 12:26 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS