start method
Implementation
Future<void> start() async {
await _bindServer(port);
if (onStarted != null) {
onStarted!();
}
_httpServer.listen((HttpRequest request) {
if (WebSocketTransformer.isUpgradeRequest(request)) {
WebSocketTransformer
.upgrade(request, compression: CompressionOptions.compressionOff)
.then((WebSocket webSocket) {
_ws = webSocket;
webSocket.listen(onWebSocketRequest, onDone: () {
_ws = null;
}, onError: (obj, stack) {
_ws = null;
});
});
} else {
onHTTPRequest(request);
}
});
}