BunWebSocketHandlerOptions
Defined in: src/io/broker/WebSocketServerAdapters.ts:124
Type Parameters
Section titled “Type Parameters”UserData
Section titled “UserData”UserData = unknown
Properties
Section titled “Properties”actorName?
Section titled “actorName?”
readonlyoptionalactorName?: (ws) =>string
Defined in: src/io/broker/WebSocketServerAdapters.ts:145
Custom actor name per connection. Defaults to a counter.
Parameters
Section titled “Parameters”BunServerWebSocketLike<BunWebSocketSlot<UserData>>
Returns
Section titled “Returns”string
onClose?
Section titled “onClose?”
readonlyoptionalonClose?: (ws,ref,code,reason) =>void
Defined in: src/io/broker/WebSocketServerAdapters.ts:134
Per-connection cleanup. Called after the actor has stopped.
Parameters
Section titled “Parameters”BunServerWebSocketLike<BunWebSocketSlot<UserData>>
number
reason
Section titled “reason”string
Returns
Section titled “Returns”void
onOpen?
Section titled “onOpen?”
readonlyoptionalonOpen?: (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).
Parameters
Section titled “Parameters”BunServerWebSocketLike<BunWebSocketSlot<UserData>>
Returns
Section titled “Returns”void
stopOnSocketClose?
Section titled “stopOnSocketClose?”
readonlyoptionalstopOnSocketClose?:boolean
Defined in: src/io/broker/WebSocketServerAdapters.ts:143
Stop the actor when the bun socket closes. Default true.
target?
Section titled “target?”
readonlyoptionaltarget?: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.