UpgradeDecision
The answer to a WebSocket upgrade: refused with a response, or accepted.
The answer to a WebSocket upgrade: refused with a response, or accepted. An accepted upgrade carries
the handshake headers (the caller writes the 101 status line before them) and start, which binds the
connection to the transport's sink and returns the input the transport feeds.
Import#
ts
import type { UpgradeDecision } from "@shadow-js/dusk/server";
Signature#
ts
type UpgradeDecision =
| { readonly kind: "reject"; readonly response: Response }
| {
readonly kind: "websocket";
/** Handshake headers of the 101 response (Upgrade, Connection, Sec-WebSocket-Accept). */
readonly headers: Readonly<Record<string, string>>;
start(sink: WebSocketSink): WebSocketInput;
/** Starts on a runtime that delivers decoded messages and owns WebSocket framing. */
startMessages?(
sink: import("./websocket").MessageWebSocketSink,
): import("./websocket").MessageWebSocketInput;
/** Validated limits, used by a native runtime to configure its own payload and heartbeat bounds. */
readonly limits?: import("./websocket").WebSocketLimits;
/**
* Tells the handler the transport will not call `start` (it could not write the 101, or the client
* went away first), so the connection slot the decision holds is given back. Safe to call more than
* once, and a no-op after `start`.
*/
abandon?(): void;
}