Remarks
Returned bygetReceivedPackets. Like NfFile, it lets you read the
payload in the format you need, but every method is synchronous since the
bytes are already in memory. Packets carry no format tag: read a packet the
way it was sent, text() for a string, json() for any other value.
Example
Constructors
Constructor
new NetworkData(Defined in: modules/network/src/shared/network-data.ts:26bytes):NetworkData
Parameters
bytes
Uint8Array
Raw payload bytes.
Returns
NetworkData
Methods
arrayBuffer()
arrayBuffer(): ArrayBuffer
Defined in: modules/network/src/shared/network-data.ts:40
Return the payload as a new ArrayBuffer.
Returns
ArrayBuffer
bytes()
bytes():Defined in: modules/network/src/shared/network-data.ts:33 Return the payload as a newUint8Array<ArrayBuffer>
Uint8Array.
Returns
Uint8Array<ArrayBuffer>
json()
json<Defined in: modules/network/src/shared/network-data.ts:56 Parse the payload as JSON and return the result.T>():T
Type Parameters
T
T = any
Returns
T
Throws
SyntaxError When the payload is not valid JSON.
text()
text(): string
Defined in: modules/network/src/shared/network-data.ts:47
Decode the payload as a UTF-8 string.
Returns
string