Every handler registered withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/foxytp/stelar-time-real/llms.txt
Use this file to discover all available pages before exploring further.
.on(), .onAck(), .onConnection(), .onDisconnect(), or .use() receives a single StelarContext object as its only argument. It bundles the client’s identity, the received payload, and every action you can take in response — sending messages, managing rooms, storing metadata, and sending ACK replies.
Properties
The unique string ID assigned to this client on connection. Generated with
randomUUID() by default, or with a custom generateClientId function if configured.The raw underlying
net.Socket. Avoid writing to it directly — use the context send methods instead. Useful for low-level checks such as ctx.socket.destroyed.The HTTP upgrade request object for WebSocket clients. Contains headers, URL, and query string. Always
null for TCP clients.The JSON-decoded payload received from the client for the current event. For binary frames, this field is set to the raw
Buffer; use ctx.buffer and ctx.isBinary to distinguish.Present on binary frames. Contains the raw bytes sent by the client. Check
ctx.isBinary === true before accessing.true when the incoming frame is binary (WebSocket OP_BINARY or TCP FRAME_BINARY). false or undefined for JSON frames.The event name that triggered this handler invocation.
Set when the context is passed to an
error event handler (registered via server.on('error', handler)). undefined for all other events.Internal identifier attached to ACK request-response cycles. Present when the incoming message is part of an ACK exchange (set by the client-side
request() call). Used by ctx.send() to route the reply back to the correct pending request. Rarely needed in application code.Full metadata record for this client. See the sub-fields below.
Send Methods
.emit(event, data)
Send a named event with a JSON payload to this specific client only.
.send(respId, data)
ACK response shorthand. Sends a reply tagged with _isAck: true and the current correlation ID back to the requesting client. Equivalent to calling ctx.emit() but with ACK metadata attached.
.emitBinary(event, buffer)
Send raw binary data to this client. The buffer is an ArrayBuffer; the server wraps it in the appropriate binary frame for the client’s protocol (WebSocket binary frame or TCP FRAME_BINARY).
.broadcast(event, data)
Send a named JSON event to all connected clients, automatically excluding the current client (self).
.broadcastBinary(event, buf)
Broadcast raw binary data to all connected clients. The current client is included (not excluded automatically — use server.broadcastBinary() from outside a handler for more control).
.to(room, event, data)
Send a JSON event to all clients in a room, excluding the current client.
.toId(id, event, data)
Send a JSON event to a specific client by ID using an O(1) indexed Map lookup.
Room Methods
.joinRoom(room)
Add the current client to a named room. Respects maxRooms and maxRoomsPerClient server limits. The server sends a joined-room confirmation frame back to the client. The onClientJoinRoom hook fires and can veto the join by returning false.
.leaveRoom(room)
Remove the current client from a named room. The room is deleted automatically when its last member leaves. The server sends a left-room confirmation frame. The onClientLeaveRoom hook fires and can veto by returning false.
.getClients(room?)
Returns the list of all connected clients, or only those in room if provided. Each entry includes the client’s ID and their current room list.
Metadata
Metadata is stored per-client in aMap<string, unknown> and persists for the lifetime of the connection. It is never sent to the client.
.setMetadata(key, value)
Store an arbitrary value on the client. Accepts any serializable or non-serializable value.
.getMetadata(key)
Retrieve a previously stored metadata value. Returns undefined if the key does not exist.
ACK
.ack(ackName, data)
Manually invoke a registered ACK handler by name and send its return value to the current client. Useful when you need to trigger an ACK response from inside a regular event handler rather than an .onAck() handler.
