start method

Future<void> start()

Implementation

Future<void> start() async {
  await _bindServer(port);

  if (onStarted != null) {
    onStarted!();
  }

  await for (HttpRequest request in _httpServer) {
    HttpHeaders headers = request.headers;
    if (headers.value('upgrade') == 'websocket') {
      _ws = await WebSocketTransformer.upgrade(request);
      _ws!.listen(onWebSocketRequest);
    } else {
      await onHTTPRequest(request);
    }
  }
}