Skip to main content
Defined in: modules/network/src/shared/packet.ts:44 A packet type, shared by the client and the server.

Remarks

Create it with definePacket, in a file both apps import. Its name is written in front of every packet of this type, so both sides must use the same one.

Type Parameters

T

T Payload type of the packet.

Properties

__payload?

readonly optional __payload?: T
Defined in: modules/network/src/shared/packet.ts:52 Never set: only keeps definitions of different payloads apart.

channel

readonly channel: Channel
Defined in: modules/network/src/shared/packet.ts:48 Channel used when send gets no channel option.

name

readonly name: string
Defined in: modules/network/src/shared/packet.ts:46 Name identifying the packet type on the wire.

validate?

readonly optional validate?: (data) => data is T
Defined in: modules/network/src/shared/packet.ts:50 Check run on every received payload, see PacketOptions.validate.

Parameters

data
unknown

Returns

data is T