Skip to content

Net Api

Functions to interact with the current connection to the server

blueboat: blueboat

Tools for sending and receiving data in non-2d modes


colyseus: colyseus

Tools for sending and receiving data and interacting with state in 2d modes

get Callbacks(): any

Colyseus’s Callbacks function for listening to state changes

any


get gamemode(): string | null

The id of the gamemode the player is currently playing

string | null


get isHost(): boolean

Whether the user is the one hosting the current game

boolean


get type(): ConnectionType

Which type of server the client is currently connected to

ConnectionType

modifyFetchRequest(path, callback): () => void

Runs a callback when a request is made that matches a certain path (can have wildcards)

Parameter Type
path string
callback (options) => any

A function to stop the modification

() => void

api.net.modifyFetchRequest("/api/experiences", (request) => {
console.log(request.data);
request.data.modified = true;
return null; // Cancel the request
});

modifyFetchResponse(path, callback): () => void

Runs a callback when a response is recieved for a request under a certain path (can have wildcards)

Parameter Type
path string
callback (response) => any

A function to stop the modification

() => void

api.net.modifyFetchResponse("/api/experience/map/hooks", (data) => {
console.log(data);
return "modified data";
});

onLoad(callback, gamemode?): () => void

Runs a callback when the game is loaded, or runs it immediately if the game has already loaded. If the @gamemode header is set the callback will only fire if the gamemode matches one of the provided gamemodes.

Parameter Type
callback (type, gamemode) => void
gamemode? string | readonly string[]

A function to cancel waiting for load

() => void