connect method

DataConnection? connect(
  1. String peer, [
  2. PeerConnectOption? options
])

Implementation

DataConnection? connect(String peer, [PeerConnectOption? options]) {
  options ??= PeerConnectOption();
  if (_disconnected) {
    logger.warn(
        'You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect.');
    emitError(PeerErrorType.Disconnected.value, 'Cannot connect to new Peer after disconnecting from server.');
    return null;
  }

  final dataConnection = _serializers[options.serialization ?? 'default']!(peer, this, options);
  _addConnection(peer, dataConnection);
  return dataConnection;
}