Send a message to all connected ServerWebSocket subscribed to a topic
Symbol
Server.publish
publish(topic: string, data: string | ArrayBuffer | SharedArrayBuffer | ArrayBufferView<ArrayBufferLike>, compress?: boolean): number
@param topic
The topic to publish to
@param data
The data to send
@param compress
Should the data be compressed? Ignored if the client does not support compression.
@returns
0 if the message was dropped, -1 if backpressure was applied, or the number of bytes sent.
server.publish("chat", "Hello World");
Referenced types
class ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.
type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> = NodeJS.TypedArray<TArrayBuffer> | DataView<TArrayBuffer>