connect method

Future<void> connect()

Implementation

Future<void> connect() async {
  reset();
  log("Connecting to $_url");
  _channel = IOWebSocketChannel.connect(_url,
      connectTimeout: const Duration(seconds: 10));
  _connected = true;
  _channel!.stream.listen(_onReceiveMessage, onError: (error) async {
    log("Websocket stream error: $_url");
    await reset();
  }, onDone: () {
    log("Websocket stream closed by remote: $_url");
    _connected = false;
  });
}