Net Api
GL.net
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) => {})
// fired when the game loads with a certain typenet.on(load:TYPE, (type) => {})
// you can also use wildcards, egnet.on("send:*", () => {})
Accessors
isHost
Get Signature
get isHost():
any
Whether the user is the one hosting the current game
Returns
any
room
Get Signature
get room():
any
The room that the client is connected to, or null if there is no connection
Returns
any
type
Get Signature
get type():
"Blueboat"
|"Colyseus"
|"None"
Which type of server the client is currently connected to
Returns
"Blueboat"
| "Colyseus"
| "None"
Methods
offLoad()
offLoad(
id
):void
Cancels any calls to onLoad with the same id
Parameters
Parameter | Type |
---|---|
id | string |
Returns
void
onLoad()
onLoad(
id
,callback
): () =>void
Runs a callback when the game is loaded, or runs it immediately if the game has already loaded
Parameters
Parameter | Type |
---|---|
id | string |
callback | (type ) => void |
Returns
Function
A function to cancel waiting for load
Returns
void
send()
send(
channel
,message
):void
Sends a message to the server on a specific channel
Parameters
Parameter | Type |
---|---|
channel | string |
message | any |
Returns
void