Message
On message
hook, you receive a message object containing data from the client.
MessageEvent
with convenient superset of utils.Instance properties
Unique random identifier (uuid v4) for the message.
Access to the original message event if available.
Access to the peer instance that emitted the message.
Raw message data (can be of any type).
Message data (value varies based on peer.binaryType
).
Get stringified text version of the message.
If raw data is in any other format, it will be automatically converted or decoded.
Get parsed version of the message text with JSON.parse()
.
Get data as Uint8Array
value.
If raw data is in any other format or string, it will be automatically converted or encoded.
Get data as ArrayBuffer
or SharedArrayBuffer
value.
If raw data is in any other format or string, it will be automatically converted or encoded.
Get data as Blob
value.
If raw data is in any other format or string, it will be automatically converted or encoded.
Instance methods
Adapter support
Bun | Cloudflare | Cloudflare (durable) | Deno | Node (ws) | Node (μWebSockets) | SSE | |
---|---|---|---|---|---|---|---|
event | ⨉ | ✓ | ⨉ | ✓ | ⨉ | ⨉ | ⨉ |