WebSocketHandler abstract class
The web socket protocol is implemented by a HTTP server handler which can be instantiated like this:
WebSocketHandler wsHandler = new WebSocketHandler();
and then its onRequest method can be assigned to the HTTP server, e.g.
server.defaultHandler = wsHandler.onRequest;
or
server.addRequestHandler((req) => req.path == "/ws",
wsHandler.onRequest);
This handler strives to implement web sockets as specified by RFC6455.
abstract class WebSocketHandler { factory WebSocketHandler() => new _WebSocketHandler(); /** * Request handler to be registered with the HTTP server. */ void onRequest(HttpRequest request, HttpResponse response); /** * Sets the callback to be called when a new web socket connection * has been established. */ void set onOpen(callback(WebSocketConnection connection)); }
Constructors
factory WebSocketHandler() #
factory WebSocketHandler() => new _WebSocketHandler();
Properties
void set onOpen(callback(WebSocketConnection connection)) #
Sets the callback to be called when a new web socket connection has been established.
void set onOpen(callback(WebSocketConnection connection));
Methods
void onRequest(HttpRequest request, HttpResponse response) #
Request handler to be registered with the HTTP server.
void onRequest(HttpRequest request, HttpResponse response);