diff --git a/networking-protocol.md b/networking-protocol.md index e731e16..3cf9304 100644 --- a/networking-protocol.md +++ b/networking-protocol.md @@ -1,38 +1,41 @@ -These are the basic networking protocols used by the client and server programs. +These are the basic networking protocols used by the client and server +programs. +This page details the _current_ working version, it omits planned features. #### Packet Types -* none "problem" +The declaration of this list can be found in +[packet_type.hpp](packet_type.hpp). -* ping "are you there?" -* pong "I am here" -* broadcast request "what servers are available?" -* broadcast response "I am available" -* join request "can I play? here's my data" -* join confirm "yes, here's your data" -* disconnect "I/you need to go" - -* synchronize "send me all of the data you've got" -* player new "create this player at this location" -* player delete "delete this player" -* player move "this is the player's new movement data" +``` + 0: none + 1: ping + 2: pong + 3: broadcast request + 4: broadcast response + 5: join request + 6: join response + 7: disconnect + 8: syncronize (unused) + 9: player new (unused) +10: player delete (unused) +11: player move (unused) +``` #### Procedures -connecting to a server: +Connecting to and disconnecting from a server: -* client sends a broadcast -* server responds with data (name, version) -* client sends a join request -* server responds with data (player index, resource list) -* client switches to resource loading/game mode -* client sends sync request +1. The client enters the Lobby scene and sends a BroadcastRequest +2. The server responds with a BroadcastResponse (including the server's name) +3. The client selects a server from the list of responses and sends a +JoinRequest to that server +4. The server either ignores the request, or adds the client to it's internal +client list and responds with a JoinResponse (including the new client's index) +5. When the client receives the response, it switches from the Lobby scene to +the InWorld scene. +6. Pressing the escape key on on the client (while in the InWorld scene) will +send a Disconnect message, and will switch the client to the MainMenu scene. +7. When the server receives the Disconnect, it will send another (at this stage +redundant) Disconnect to the client, and remove it from the list of clients. -in the game: - -* either sends player new command -* either receives player new command; server relays this command -* either sends player delete command -* either receives player delete command; server relays this command -* either sends player move command -* either receives player move command; server relays this command \ No newline at end of file