Skip to main content
Markdown

Publishing

Your server sends events to channels with its secret. Browsers can't publish: they send client events to each other at most.

await realtime.publish( 'private-orders-42', 'updated', { status: 'paid' } );
Argument
channelsone name, or up to 100
eventany name but realtime:…
dataanything JSON takes, up to 10 KB
except (Python except_tab)a tab (the browser's rt.tab, sent with the request that caused it), which doesn't get it back. Laravel's toOthers() takes it from the request's X-Socket-ID header
sealfalse sends a private or presence channel's data in plain
  • Sealed by default: a private or presence channel's data goes sealed with its key, a copy each. Public channels' data goes in plain, together.
  • A refusal throws a RealtimeError with the server's code and HTTP status (errors); Laravel's broadcasting throws a BroadcastException. Publish after your own work is saved: a failed publish is a missed live update, not a lost change.

Several events at once, and what a channel holds now:

await realtime.publishBatch( [
{ channels: 'private-orders-42', event: 'updated', data: { status: 'paid' } },
{ channels: 'orders', event: 'count', data: { open: 7 } },
] ); // 10 events a request

const info = await realtime.channelInfo( 'presence-room-7' ); // { subscriptions, members: { count, list } }