Net Api
The net api extends EventEmitter2 and uses wildcards with ”:” as a delimiter.
The following events are emitted:
// fired when data is recieved on a certain channelnet.on("CHANNEL", (data, editFn) => {})
// fired when data is sent on a certain channelnet.on("send:CHANNEL", (data, editFn) => {})
// you can also use wildcards, egnet.on("send:*", () => {})Accessors
Section titled “Accessors”gamemode
Section titled “gamemode”Get Signature
Section titled “Get Signature”get gamemode():
string
The id of the gamemode the player is currently playing
Returns
Section titled “Returns”string
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 room():
any
The 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 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”Function
Returns
Section titled “Returns”void
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”Function
Returns
Section titled “Returns”void
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 | string[] |
Returns
Section titled “Returns”Function
A function to cancel waiting for load
Returns
Section titled “Returns”void
send()
Section titled “send()”send(
channel,message?):void
Sends a message to the server on a specific channel
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel | string |
message? | any |
Returns
Section titled “Returns”void