API reference / @chanx-js/server / core / Context
Interface: Context<Path, State, User, Emits>
Defined in: packages/server/src/consumer.ts:55
What a consumer's handlers and hooks get as ctx.
Type Parameters
| Type Parameter |
|---|
Path extends string |
State |
User |
Emits extends Message |
Properties
conn
readonly conn: Connection<Path, User>;Defined in: packages/server/src/consumer.ts:56
params
readonly params: PathParams<Path>;Defined in: packages/server/src/consumer.ts:58
Params parsed from the route: /ws/chat/{room} gives room.
ref
readonly ref: string | undefined;Defined in: packages/server/src/consumer.ts:62
The ref of the frame being handled, echoed on every reply.
signal
readonly signal: AbortSignal;Defined in: packages/server/src/consumer.ts:64
Aborts when the connection closes, so long-running work can stop.
state
readonly state: State;Defined in: packages/server/src/consumer.ts:60
Per-connection state, from the state option.
Methods
broadcast()
broadcast(message, options?): Promise<void>;Defined in: packages/server/src/consumer.ts:70
Send to every connection in the groups, across processes.
Parameters
| Parameter | Type |
|---|---|
message | Emits |
options? | BroadcastOptions |
Returns
Promise<void>
push()
push(message): Promise<void>;Defined in: packages/server/src/consumer.ts:68
Send on this connection as a server push, without a ref.
Parameters
| Parameter | Type |
|---|---|
message | Emits |
Returns
Promise<void>
send()
send(message): Promise<void>;Defined in: packages/server/src/consumer.ts:66
Send on this connection, stamped with the frame's ref.
Parameters
| Parameter | Type |
|---|---|
message | Emits |
Returns
Promise<void>