Skip to main content

httpSend()

httpSend(event: string, payload: any, opts?: { timeout?: number }): Promise<{ success: true } | { success: false; status: number; error: string }>

Always send Broadcast over HTTP, regardless of WebSocket state. ArrayBuffer / ArrayBufferView are sent as application/octet-stream; everything else is JSON. If you create a channel only to send, call removeChannel() afterwards.

Parameters

event
string

Broadcast event name

payload
any

Message body; required

opts
{ timeout?: number }

Timeout and other options

Response

Promise
object

Resolves to { success: true } on success

Example

const channel = realtime.channel("room");
try {
await channel.httpSend("cursor-pos", { x: 12, y: 40 });
} finally {
await realtime.removeChannel(channel);
}