basalt / realtime/src / RealtimeHub
Class: RealtimeHub
Defined in: realtime/src/hub.ts:87
The neutral core: tracks connections, their channel subscriptions and presence, and delivers messages. All I/O (sockets, Redis) is behind the Connection and RealtimeBackplane seams.
Constructors
Constructor
> new RealtimeHub(backplane?, options?): RealtimeHub
Defined in: realtime/src/hub.ts:93
Parameters
backplane?
RealtimeBackplane = ...
options?
RealtimeHubOptions = {}
Returns
RealtimeHub
Methods
close()
> close(): Promise<void>
Defined in: realtime/src/hub.ts:243
Returns
Promise<void>
count()
> count(tenantId, channel): number
Defined in: realtime/src/hub.ts:189
Live connection count for (tenant, channel) on this node.
Parameters
tenantId
string
channel
string
Returns
number
presence()
> presence(tenantId, channel): string[]
Defined in: realtime/src/hub.ts:183
The distinct user ids currently subscribed to (tenant, channel) on this node.
Parameters
tenantId
string
channel
string
Returns
string[]
publish()
> publish(tenantId, channel, event, data): Promise<void>
Defined in: realtime/src/hub.ts:173
Publishes to every subscriber of (tenant, channel), across all instances.
Parameters
tenantId
string
channel
string
event
string
data
unknown
Returns
Promise<void>
register()
> register(connection): void
Defined in: realtime/src/hub.ts:103
Parameters
connection
Returns
void
start()
> start(): Promise<void>
Defined in: realtime/src/hub.ts:99
Wire the backplane so cross-instance messages reach local connections.
Returns
Promise<void>
subscribe()
> subscribe(connectionId, channel): Promise<boolean>
Defined in: realtime/src/hub.ts:130
Attaches a connection to a channel. Returns whether the subscription was accepted — false when the connection is unknown (or was unregistered or replaced while authorize was pending), the channel is not a string or is empty/too long, the per-connection cap is reached, or the authorize gate refused it. Adapters SHOULD check the result and signal/close on refusal.
Parameters
connectionId
string
channel
string
Returns
Promise<boolean>
unregister()
> unregister(connectionId): void
Defined in: realtime/src/hub.ts:115
Parameters
connectionId
string
Returns
void
unsubscribe()
> unsubscribe(connectionId, channel): void
Defined in: realtime/src/hub.ts:167
Parameters
connectionId
string
channel
string
Returns
void