Documentation
Interfaces
server.Server

Interface: Server<E>

server.Server

Type parameters

NameType
Eundefined

Methods

opened

opened(socket, ctxExtra): (code?: number, reason?: string) => Promise<void>

New socket has been established. The lib will validate the protocol and use the socket accordingly. Returned promise will resolve after the socket closes.

The second argument will be passed in the extra field of the Context. You may pass the initial request or the original WebSocket, if you need it down the road.

Returns a function that should be called when the same socket has been closed, for whatever reason. The close code and reason must be passed for reporting to the onDisconnect callback. Returned promise will resolve once the internal cleanup is complete.

Parameters

NameType
socketWebSocket
ctxExtraE

Returns

fn

▸ (code?, reason?): Promise<void>

Parameters
NameType
code?number
reason?string
Returns

Promise<void>

Defined in

src/server.ts:417