ws-asyncapi API / client / PresenceApi
Interface: PresenceApi<State>
Defined in: .api-entries/client/index.d.ts:189
The client.presence surface, typed by the channel's .presence schema.
Type Parameters
State
State
Properties
self
readonlyself:string
Defined in: .api-entries/client/index.d.ts:191
this connection's own socket id (known once the roster is hydrated)
Methods
set()
set(
state):Promise<void>
Defined in: .api-entries/client/index.d.ts:197
Announce or update this connection's presence state. Resolves once the server has accepted it and returned the current roster (which hydrates get/subscribe); rejects with an RpcError if rejected.
Parameters
state
State
Returns
Promise<void>
update()
update(
patch):void
Defined in: .api-entries/client/index.d.ts:205
Volatile presence update — the cursor hot path. Fire-and-forget (no ack, no roster snapshot), last-write-wins, dropped while offline, and coalesced to the latest per presenceThrottle window. Merges the patch into the last-known state, so update({ cursor }) keeps other fields. Call set once first to join the roster.
Parameters
patch
Partial<State>
Returns
void
clear()
clear():
Promise<void>
Defined in: .api-entries/client/index.d.ts:207
Leave presence (stay connected). Other members receive a leave diff.
Returns
Promise<void>
get()
get():
Map<string,State>
Defined in: .api-entries/client/index.d.ts:209
The current cached roster: socket id → state.
Returns
Map<string, State>
subscribe()
subscribe(
callback): () =>void
Defined in: .api-entries/client/index.d.ts:215
Observe the roster live. The callback fires with the full roster on every change (join/leave/update). Returns an unsubscribe function. The first subscriber triggers a snapshot fetch if the roster isn't hydrated yet.
Parameters
callback
(members) => void
Returns
() => void