-
Notifications
You must be signed in to change notification settings - Fork 0
Protocol
Masoug edited this page Dec 6, 2013
·
1 revision
The protocol system relies on Google Protobufs. All data that is sent between the computers is based on the NetPacket object that encapsulates all other objects. Each netpacket has a type() method that tells you what its payload is. This encapsulating paradigm is used for the field events too.
-
PlayerRequestsends the desired username to the server, and the server will send aPlayerConfirmationwith the assigned player id. -
FieldEvents are realtime updates that all clients and servers receive and respond to. For example, if a player pushes awkey to move forward, the client will send aPlayerEvent(wrapped within aFieldEventwhich is again wrapped in aNetPacket) with the new velocity vector that the player is going in to the server. The server applies the change to its state and rebroadcasts the field event to all other clients (who applies the update too). This provides the fast, lightweight realtime updates that allows clients to approximate/interpolate the server's game state. -
GameStatestores the entire details of the game's state (even though some of information is redundant). The server's game state is broadcast to each client every 1/8th of a second, and the positional differences between the server's state and the client's state are corrected by applying an impulse (proportional to how far the object is from its supposed position). The 1/8th-second frequency is just enough to keep the interpolation smooth-looking.