Skip to main content
Defined in: modules/network/src/client/network-client-context.type.ts:18 Typed packets of the client, exposed as ctx.network.packets.

Example

Methods

on()

on<T>(packet, listener): () => void
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).

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 or validate.

read()

read<T>(packet): (ClientPacketInfo & object)[]
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.

Type Parameters

T
T

Parameters

packet
PacketDefinition<T>

Returns

(ClientPacketInfo & object)[]

Throws

When another definition with the same name has another channel or validate.

send()

send<T>(packet, …args): void
Defined in: modules/network/src/client/network-client-context.type.ts:46 Send a packet to the server, on the definition’s channel unless another 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, or data cannot be encoded as JSON.