ctx.network.packets.
Example
Methods
on()
on<Defined in: modules/network/src/client/network-client-context.type.ts:27 Be notified of every packet of a type, each tick before the ECS systems (not while paused).T>(packet,listener): () =>void
Type Parameters
T
T
Parameters
packet
PacketDefinition<T>
listener
PacketListener<NoInfer<T>, ClientPacketInfo>
Returns
A function that removes the listener. () =>void
Throws
When another definition with the same name has another channel orvalidate.
read()
read<Defined in: modules/network/src/client/network-client-context.type.ts:37 Return the packets of a type received this tick, for an ECS system.T>(packet): (ClientPacketInfo&object)[]
Type Parameters
T
T
Parameters
packet
PacketDefinition<T>
Returns
(ClientPacketInfo & object)[]
Throws
When another definition with the same name has another channel orvalidate.
send()
send<Defined in: modules/network/src/client/network-client-context.type.ts:46 Send a packet to the server, on the definition’s channel unless anotherT>(packet, …args):void
channel is given. data is left out for a packet without payload:
send(Play).
Type Parameters
T
T
Parameters
packet
PacketDefinition<T>
args
…PacketArgs<NoInfer<T>>
Returns
void
Throws
When the channel’s port was not configured, ordata cannot be
encoded as JSON.