Websocket support for HTTP servers



WebSocket connections are accepted using a request-response pair from an existing HTTP connection.


If a function is returned, it is called with each message received from the client on the connection.


maxLength is measured in bytes per message frame, and must be less than 2^48. If defined, origin, protocols, and extensions are compared against the request headers to determine if a request is acceptable. protocols and extensions are specified in decreasing priority order.

ConnectionsendmessagestringArrayBuffercallbackundefinedinfoSendInfoConnectionclosecode1000numberreason'Normal Closure'stringonMessagemessagestringArrayBufferonErrorcodenumbersocketClientSocket

Messages are received from the client by setting the connection's onMessage listener or returning the listener from ConnectCallback. When terminated by the client, or on any protocol error, the connection is automatically closed and onError is called with the WebSocket error code. ClientSocket and SendInfo are defined in the socket module.