Skip to content
Neil Moore edited this page Apr 6, 2015 · 5 revisions

Network

This page details the proposed network architecture and implementation details for the client/server communication via local WiFi and Internet.

Network Architecture

Current (as of 1/27/2015) architecture is to do a client-server relationship model where either a player would choose to be a local server via WiFi Direct or the players would join a session on an external Internet server.

Local Server (Local WiFi)

When a player chooses to be the server for the group, they then becomes both the control server and a client. They can interact with the game like any other player, but each of the other players relies on calculations done on the control server to display enemy movement/damage and game progression.

Internet Server

When players connect to an outside server and join a session (denoted by an ID of some sort), they are now reliant upon the server's calculations and data. The server would not be a player in this instance.

Packet Structure

The packet structure for communicating between client and server should be concise yet comprehensive. Using a consistent and serializable (able to be converted to a binary or string representation easily) class would be essential as then we can pass larger amounts of data without having to use a container such as JSON or XML.

As the data that needs to be shared between the server and the clients hasn't been determined yet, we shouldn't worry too much about creating a packet structure.

How it Works

Instead of using a master-slave model, since we already have most of the client code up and running, we have decided to leverage that extensively. In multiplayer, each client has a portion of the overall map, and thus there is little need for communication between the various clients. Due to this, the only actions we currently need to be sending between the Client and Server are:

  • When a live enemy moves off the screen, or reaches the end (Client -> Server)
  • When a wave starts (Server -> Client)
  • When a gameover scenario occurs (Server -> Clients)
  • Resource management (Server <-> Clients)
  • ???

However, we plan on recording all actions that affect the gamestate, so if we make significant changes to how the network architecture works, we can easily make those changes without having to refactor the client/gameplay side significantly, if at all.

Special Packets

###ActionCreateWave Clients are expecting multipliers(Refer to EnemyManager.calculateWave()) and number of enemies. Generate packet accordingly.