connect method

void connect()

Implementation

void connect() async {
  try {
    if (retryCount <= maxRetryCount) {
      retryCount++;
      //https://github.com/dart-lang/web_socket_channel/issues/61#issuecomment-585564273
      var ws = await WebSocket.connect(url!).timeout(const Duration(seconds: 5));
      channel = IOWebSocketChannel(ws);
      listenEvents();
    } else {
      emit('failed');
    }
  } catch (error) {
    // print(error);
    connect();
  }
}