Skip to content

Serverpackage

Max edited this page Jun 7, 2021 · 1 revision

Type guide

  • 1 - Update LobbyData (not implemented yet => )
  • 2 - Update HighscoreList
  • 3 - new Player Position
  • 4 - Update PlayerPosList and HighscoreList
  • 5 - Chatmessage (user join and leave)

Package structure

All interfaces mentioned in this wiki entry are defined in the Objecthelper Packages received from clients get unpacked into an interface of the following structure:

type  ReturnMessage  struct {
	Type int  `json:"type"`
	LobbyData LobbyData `json:"LobbyData"`
	Highscore []HighScoreStruct `json:"highscore"`
	PlayerPos []PlayerPosition `json:"playerpos"`
	ChatMessage string  `json:"chat"`
}

When sending packages to the server it is important to use the json tags for the data. The two other interfaces relevant for the client package are LobbyData, HighscoreStruct, PlayerPosition:

LobbyData:

type  LobbyData  struct {
	ID string  `json:"LobbyID"`
	MapCode string  `json:"MapID"`
	LobbyName string  `json:"Name"`
}

HighscoreStruct:

type  HighScoreStruct  struct {
PlayerName string
Time int64
}

PlayerPosition:

type  PlayerPosition  struct {
	Name string  `json:"PlayerName"`
	PosX int  `json:"y"`
	PosY int  `json:"x"`
	VelX int  `json:"yVel"`
	VelY int  `json:"xVel"`
	IsDashing bool  `json:"isDashing"`
}

All playernames are filled in by the server based on the name that the client provided when first connecting. This is a countermeasure to prevent any harm from data that has been tampered with.

Clone this wiki locally