Skip to content

BunWebSocketHandlerOptions

Defined in: src/io/broker/WebSocketServerAdapters.ts:124

UserData = unknown

readonly optional actorName?: (ws) => string

Defined in: src/io/broker/WebSocketServerAdapters.ts:145

Custom actor name per connection. Defaults to a counter.

BunServerWebSocketLike<BunWebSocketSlot<UserData>>

string


readonly optional onClose?: (ws, ref, code, reason) => void

Defined in: src/io/broker/WebSocketServerAdapters.ts:134

Per-connection cleanup. Called after the actor has stopped.

BunServerWebSocketLike<BunWebSocketSlot<UserData>>

ActorRef<WebSocketCmd>

number

string

void


readonly optional onOpen?: (ws, ref) => void

Defined in: src/io/broker/WebSocketServerAdapters.ts:132

Per-connection setup. Receives the freshly-spawned actor ref so caller code can register it with chatrooms, persistence layers, routers, etc. The optional return value is forwarded as target for the actor — handy if you build the target lazily from the upgrade context (e.g. one room actor per URL path).

BunServerWebSocketLike<BunWebSocketSlot<UserData>>

ActorRef<WebSocketCmd>

void


readonly optional stopOnSocketClose?: boolean

Defined in: src/io/broker/WebSocketServerAdapters.ts:143

Stop the actor when the bun socket closes. Default true.


readonly optional target?: ActorRef<WebSocketFrame>

Defined in: src/io/broker/WebSocketServerAdapters.ts:141

Static target for every actor spawned by this handler set. If omitted, callers register the per-connection target inside onOpen via ref.tell(...) to a router that knows where to forward.