websocket method

Future<WebSockets> websocket({
  1. String path = '/ws',
  2. Duration? timeout,
})

Opens a WebSockets connection to the server. This will automatically bind the server over HTTP, if it is not already listening. Unfortunately, WebSockets cannot be mocked (yet!).

Implementation

Future<client.WebSockets> websocket(
    {String path = '/ws', Duration? timeout}) async {
  if (_http.server == null) await _http.startServer();
  var url = _http.uri.replace(scheme: 'ws', path: path);
  var ws = _MockWebSockets(this, url.toString());
  await ws.connect(timeout: timeout);
  return ws;
}