reconnect method

void reconnect()

Implementation

void reconnect() async {
  if (_disconnected && !_destroyed) {
    logger.log('Attempting reconnection to server with ID $_lastServerId');
    _disconnected = false;
    await _initialize(_lastServerId!);
  } else if (_destroyed) {
    throw Exception('This peer cannot reconnect to the server. It has already been destroyed.');
  } else if (!_disconnected && !_open) {
    logger.error('In a hurry? We\'re still trying to make the initial connection!');
  } else {
    throw Exception('Peer $id cannot reconnect because it is not disconnected from the server!');
  }
}