send
constsend:any=addon.send
Defined in: index.cts:475
Sends data to a specific WebSocket connection, multiple connections, or broadcasts to all subscribers of a channel.
target
The target for the message:
- A socket ID (number): sends to that specific socket
- A channel name (Buffer, ArrayBuffer, or string): broadcasts to all subscribers of that channel
- An array of socket IDs and/or channel names: sends to each socket and broadcasts to each channel
data
The data to send (Buffer, ArrayBuffer, or string).
Returns
Section titled “Returns”the number of recipients that got sent the message.
When target is a virtual socket with user prefix (or a channel that has such a subscriber), that prefix is prepended to the message. In case of a text message, the prefix bytes are assumed to be valid UTF-8.
When target is an array, the message is sent to each target in the array.