Colyseus Api
api.net.colyseus
Section titled “api.net.colyseus”The colyseus api is for sending and recieving data in 2d modes.
// fired when data is recieved on a certain channelapi.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 channelapi.net.colyseus.on("send:CHANNEL", (data) => { return null; // Cancel the data being sent});Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get room():
any
The colyseus room that the client is connected to, or null if there is no connection
Returns
Section titled “Returns”any
Get Signature
Section titled “Get Signature”get state():
GimkitSchema
Gimkit’s internal Colyseus state
Returns
Section titled “Returns”GimkitSchema
Methods
Section titled “Methods”off<
C>(channel,listener):void
Removes a listener added by on or once
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
C extends keyof Messages2d |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel |
C |
listener |
(data) => void | Messages2d[C] | null |
Returns
Section titled “Returns”void
offAny()
Section titled “offAny()”offAny(
listener):void
Removes a listener added by onAny
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener |
(channel, data) => any |
Returns
Section titled “Returns”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
C extends keyof Messages2d |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel |
C |
listener |
(data) => void | Messages2d[C] | null |
Returns
Section titled “Returns”void
onAny()
Section titled “onAny()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener |
(channel, data) => any |
Returns
Section titled “Returns”void
once()
Section titled “once()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
C extends keyof Messages2d |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel |
C |
listener |
(data) => void | Messages2d[C] | null |
Returns
Section titled “Returns”void
send()
Section titled “send()”send<
C>(channel, …args):void
Sends a message to the server on a specific channel
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
C extends keyof SentMessages2d |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel |
C |
data |
any |
Returns
Section titled “Returns”void
sendDirect()
Section titled “sendDirect()”sendDirect<
C>(channel, …args):void
Sends a message to the server on a specific channel, bypassing listeners added by plugins
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
C extends keyof SentMessages2d |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel |
C |
data |
any |
Returns
Section titled “Returns”void