publish

Bun

Symbol

ServerWebSocket.publish

publish(topic: string, data: string | BufferSource, compress?: boolean): number

Sends a message to subscribers of the topic.

@param topic

The topic name.

@param data

The data to send.

@param compress

Should the data be compressed? If the client does not support compression, this is ignored.

ws.publish("chat", "Hello!");
ws.publish("chat", "Compress this.", true);
ws.publish("chat", new Uint8Array([1, 2, 3, 4]));

Referenced types

type BufferSource = NodeJS.TypedArray | DataView | ArrayBufferLike