The lifecycle callbacks an application supplies per WebSocket route.
Every callback may be async; a rejected promise is routed to
WebSocketHandlers.onError rather than becoming an unhandled
rejection.
optional
onOpen(conn: IWebSocketConnection,context: WebSocketConnectionContext): void | Promise<void>
Called once per connection, after the handshake completes.
optional
onMessage(conn: IWebSocketConnection,data: string | Uint8Array): void | Promise<void>
Called for every inbound frame.
optional
onClose(conn: IWebSocketConnection,event: WebSocketCloseEvent): void | Promise<void>
Called once, when the connection closes for any reason.
optional
onError(conn: IWebSocketConnection,error: Error): void | Promise<void>
Called on a transport error, and on a rejected promise from any other callback.