NetworkClientLibrary, exposed on Context.network.
Remarks
Every method takes an optional{ channel }. Reliable channels need
SERVER_TCP_PORT, unreliable ones SERVER_UDP_PORT; using a channel whose
port is not configured throws.
Properties
clientId
Defined in: modules/network/src/client/network-client-context.type.ts:61 Client id assigned by the server, shared by TCP and UDP.readonlyclientId:string|undefined
undefined until welcomed.
inviteLink
Defined in: modules/network/src/client/network-client-context.type.ts:65 Link to send to other players so they join this peer-to-peer game,readonlyinviteLink:string|undefined
undefined otherwise.
packets
Defined in: modules/network/src/client/network-client-context.type.ts:59 Typed packets: per-type listeners,readonlypackets:ClientPacketsApi
read and send.
roomCode
Defined in: modules/network/src/client/network-client-context.type.ts:63 Code of the peer-to-peer game this player hosts or joined,readonlyroomCode:string|undefined
undefined otherwise.
Methods
getReceivedPackets()
getReceivedPackets(Defined in: modules/network/src/client/network-client-context.type.ts:76 Return the packets received since the last call, fromoptions?):NetworkData[]
channel or from
every configured channel. Call it once per frame:
packets left unread for a whole tick are dropped.
Parameters
options?
ChannelOptions
Returns
NetworkData[]
isConnected()
isConnected(Defined in: modules/network/src/client/network-client-context.type.ts:78 Returnoptions?):boolean
true when channel, or every configured channel, is connected.
Parameters
options?
ChannelOptions
Returns
boolean
sendData()
sendData(Defined in: modules/network/src/client/network-client-context.type.ts:70 Send bytes, a string or a JSON value to the server, ondata,options?):void
Channel.ReliableOrdered unless another channel is given.
Parameters
data
NetworkPayload
options?
ChannelOptions
Returns
void