connect method

void connect()

Implementation

void connect() async {
  try {
    if (retryCount <= maxRetryCount!) {
      retryCount++;
      socket = IO.io(url, <String, dynamic>{
        'transports': ['websocket'],
        'autoConnect': true,
      });

      print(url);

      socket!.connect();
      socket!.onConnect((data) => {print('Connect: ${socket!.id}')});
      listenEvents();
    } else {
      emit('failed');
    }
  } catch (error) {
    print(error);
    connect();
  }
}