connect method

Future<void> connect()

Connects to the ATEM switcher.

Implementation

Future<void> connect() async {
  if (_connected) return;

  try {
    _socket = await RawDatagramSocket.bind(InternetAddress.anyIPv4, 0)
        .timeout(_config.timeout);

    _socketSubscription = _socket!.listen(_onSocketEvent);

    // Start handshake
    _sendSyn();

    // Start keepalive
    _startKeepAlive();

    // Start retransmission timer
    _startRetransmitTimer();
  } catch (e, st) {
    _events.add(AtemError(e, st));
    rethrow;
  }
}