Skip to content

Colyseus Api

The colyseus api is for sending and recieving data in 2d modes.

// fired when data is recieved on a certain channel
api.net.colyseus.on("CHANNEL", (data) => {
return "new data"; // Replace the data with "new data" before Gimkit processes it
});
// fired when data is sent on a certain channel
api.net.colyseus.on("send:CHANNEL", (data) => {
return null; // Cancel the data being sent
});

get room(): any

The colyseus room that the client is connected to, or null if there is no connection

any


get state(): GimkitSchema

Gimkit’s internal Colyseus state

GimkitSchema

off<C>(channel, listener): void

Removes a listener added by on or once

Type Parameter
C extends keyof Messages2d
Parameter Type
channel C
listener (data) => void | Messages2d[C] | null

void


offAny(listener): void

Removes a listener added by onAny

Parameter Type
listener (channel, data) => any

void


on<C>(channel, listener): void

Listens for an incoming or outgoing message on a specific channel. Returning a value from the listener updates what is received. Returning null cancels the message entirely.

Type Parameter
C extends keyof Messages2d
Parameter Type
channel C
listener (data) => void | Messages2d[C] | null

void


onAny(listener): void

Listens for any messages on any channel. Returning a value from the listener updates what is sent. Returning null cancels the message entirely.

Parameter Type
listener (channel, data) => any

void


once<C>(channel, listener): void

Listens for the next incoming or outgoing message on a specific channel. Returning a value from the listener updates what is received. Returning null cancels the message entirely.

Type Parameter
C extends keyof Messages2d
Parameter Type
channel C
listener (data) => void | Messages2d[C] | null

void


send<C>(channel, …args): void

Sends a message to the server on a specific channel

Type Parameter
C extends keyof SentMessages2d
Parameter Type
channel C
data any

void


sendDirect<C>(channel, …args): void

Sends a message to the server on a specific channel, bypassing listeners added by plugins

Type Parameter
C extends keyof SentMessages2d
Parameter Type
channel C
data any

void