Net Api
Functions to interact with the current connection to the server
Properties
Section titled “Properties”blueboat
Section titled “blueboat”blueboat:
blueboat
Tools for sending and receiving data in non-2d modes
colyseus
Section titled “colyseus”colyseus:
colyseus
Tools for sending and receiving data and interacting with state in 2d modes
Accessors
Section titled “Accessors”Callbacks
Section titled “Callbacks”Get Signature
Section titled “Get Signature”get Callbacks():
any
Colyseus’s Callbacks function for listening to state changes
Returns
Section titled “Returns”any
gamemode
Section titled “gamemode”Get Signature
Section titled “Get Signature”get gamemode():
string|null
The id of the gamemode the player is currently playing
Returns
Section titled “Returns”string | null
isHost
Section titled “isHost”Get Signature
Section titled “Get Signature”get isHost():
boolean
Whether the user is the one hosting the current game
Returns
Section titled “Returns”boolean
Get Signature
Section titled “Get Signature”get type():
ConnectionType
Which type of server the client is currently connected to
Returns
Section titled “Returns”ConnectionType
Methods
Section titled “Methods”modifyFetchRequest()
Section titled “modifyFetchRequest()”modifyFetchRequest(
path,callback): () =>void
Runs a callback when a request is made that matches a certain path (can have wildcards)
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path |
string |
callback |
(options) => any |
Returns
Section titled “Returns”A function to stop the modification
() => void
Example
Section titled “Example”api.net.modifyFetchRequest("/api/experiences", (request) => { console.log(request.data); request.data.modified = true;
return null; // Cancel the request});modifyFetchResponse()
Section titled “modifyFetchResponse()”modifyFetchResponse(
path,callback): () =>void
Runs a callback when a response is recieved for a request under a certain path (can have wildcards)
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path |
string |
callback |
(response) => any |
Returns
Section titled “Returns”A function to stop the modification
() => void
Example
Section titled “Example”api.net.modifyFetchResponse("/api/experience/map/hooks", (data) => { console.log(data); return "modified data";});onLoad()
Section titled “onLoad()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
callback |
(type, gamemode) => void |
gamemode? |
string | readonly string[] |
Returns
Section titled “Returns”A function to cancel waiting for load
() => void