Skip to content

Server Protocol V2.0

Thomas Lu edited this page Jan 9, 2025 · 1 revision

This page explains the protocol between client and server.

Communication graph - Initialization

image

Communication graph - ongoing Game & Disconnect

image

Server To Client (Client Listen)

Tag "yourId"

contains:

  • String contains the Id of the current socket.

Tag "init" (currently functions the same as updateAllPlayers)

contains:

  • Map<String, PlayerData>
  • String contains the id (id of the socket) of all players on the server.
  • PlayerData contains the information of all players on the server. Stored in class PlayerData.

Tag "updateAllPlayers"

Every time the client receives this data package, the status of all players on clients will be updated. Including position, hp, items, rotation

contains:

  • Map<String, PlayerData>
  • String contains the id (id of the socket) of all players on the server.
  • PlayerData contains the information of all players on the server.

Tag "playerLeft"

contains:

  • String contains the Id (id of the socket) of the left player.

Tag "initializeSeed"

contains:

  • String contains the seed of the server.

Tag "playerAction"

contains:

  • String playerID The id of the targeted player, who has done this action
  • String actionType defines what kinds of action the player has done.
  • <extra information> (undefined data structure) according to the action type, this data package may have different data.

actionType=="Fireball"

The targeted player casts a fireball

actionType=="TakeDamage"

  • float damage The targeted player recieves the damage.

Server To Client (Server Send)

Tag "updatePosition"

The position and direction of the player will be updated.

contains

  • float x x world position
  • float y y world position
  • float Rx x rotation vector
  • float Ry y rotation vector

Tag "init"

contains

  • float x x world position
  • float y y world position
  • String name name of the player
  • float hp
  • String classtype class of the player ("Mage" e.g)

##Tag "playerAction" contains:

  • String targetId The id of the targeted player, who has done this action
  • String actionType defines what kinds of action the player has done.
  • <extra information> (undefined data structure) according to the action type, this data package may have different data.

actionType=="Fireball"

The targeted player casts a fireball

actionType=="TakeDamage"

  • float damage The targeted player recieves the damage.