NetworkServerLibrary, exposed on Context.network.
Remarks
Every method takes an optional{ channel }. Reliable channels need
LISTENING_TCP_PORT, unreliable ones LISTENING_UDP_PORT; using a channel
whose port is not configured throws.
Properties
clients
Defined in: modules/network/src/server/network-server-context.type.ts:74 Client sessions, shared by TCP and UDP: lookup and connect/disconnect callbacks.readonlyclients:ClientsApi
packets
Defined in: modules/network/src/server/network-server-context.type.ts:72 Typed packets: per-type listeners,readonlypackets:ServerPacketsApi
read and sending.
Methods
getClientInfo()
getClientInfo(Defined in: modules/network/src/server/network-server-context.type.ts:94 Return what is known about a client session,clientId):ClientInfo|undefined
undefined once it is gone.
Parameters
clientId
string
Returns
ClientInfo | undefined
getConnectedClients()
getConnectedClients(Defined in: modules/network/src/server/network-server-context.type.ts:92 Return the clients reachable onoptions?):string[]
channel, or on any configured channel.
Parameters
options?
ChannelOptions
Returns
string[]
getReceivedPackets()
getReceivedPackets(Defined in: modules/network/src/server/network-server-context.type.ts:90 Return the packets each client sent since the last call, fromoptions?):Map<string,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
Map<string, NetworkData[]>
sendToAll()
sendToAll(Defined in: modules/network/src/server/network-server-context.type.ts:79 Send bytes, a string or a JSON value to every client, ondata,options?):void
Channel.ReliableOrdered unless another channel is given.
Parameters
data
NetworkPayload
options?
ChannelOptions
Returns
void
sendToClient()
sendToClient(Defined in: modules/network/src/server/network-server-context.type.ts:84 Send bytes, a string or a JSON value to one client, onclientId,data,options?):void
Channel.ReliableOrdered unless another channel is given.
Parameters
clientId
string
data
NetworkPayload
options?
ChannelOptions
Returns
void