sendConnect method

Future<bool> sendConnect(
  1. InternetAddress addr,
  2. int port,
  3. List<int> observedAddr
)

Sends a DCUtR CONNECT message to addr:port and transitions the state machine with onConnectSent().

Implementation

Future<bool> sendConnect(
  InternetAddress addr,
  int port,
  List<int> observedAddr,
) async {
  final message = DCUtRHandler().initiateConnect(observedAddr);
  final bytes = Uint8List.fromList([..._magic, ...message.serialize()]);
  _socket.send(bytes, addr, port);
  _stateMachine.onConnectSent();
  return true;
}