Skip to content

Objecthelper

Max edited this page Jun 7, 2021 · 1 revision

This defines interfaces used within the project.

Client struct

This interface holds all values that define a client. These include the Playername, the PlayerID (currently unused), the websocket connection and the Pool(Lobby) that the client is connected to. Once a client has been authenticated this structure gets created and represents the client from thereon out.
Sample usage:

var client := Client{
	Playername: "wiki"
	ID: "none"
	Conn: clientConn
	Pool: connectedPool
}

Pool

This interface holds all values that define a Pool (server side representation of a lobby). It consists of multiple channels for user join/leave, highscore updates, player position updates and broadcast messages.
Sample Usage:

newPool := Pool{
	UserJoin: make(chan *Client),
	UserLeave: make(chan *Client),
	Clients: make(map[*Client]bool),
	Broadcast: make(chan ObjectStructures.ReturnMessage),
	TimeList: make(map[int]ObjectStructures.HighScoreStruct),
	TimeListSet: make(chan ObjectStructures.HighScoreStruct),
	UserStateList: make(map[int]ObjectStructures.PlayerPosition),
	UserStateSet: make(chan ObjectStructures.PlayerPosition),
}

LobbyData

This interface stores all values for a Lobby. It is used as a representation of the lobby that can be send to clients and the masterserver.
It contains the LobbyID (this is the ID used to join a Lobby), the code for the current map and the lobbyname.
Sample usage:

newLobby := {
	ID: "sampleID"
	MapCode: "sampleMap"
	LobbyName: "sampleLobby"
}

ClientMessage

Refer to the [wiki entry](Client Package) for this specific package structure

AuthMessage

Refer to the [wiki entry](Client Package) for the ClientMessage.

ReturnMessage

Refer to the [wiki entry](Server Package) for this specific package structure

HighScoreStruct

Refer to the [wiki entry](Server Package) for the Server message.

PlayerStats

Refer to the [wiki entry](Server Package) for the Server message.

Clone this wiki locally