connect method

Future<bool> connect()

Implementation

Future<bool> connect() async {
  connectionDidClose = false;

  if (null == _castSession) {
    _castSession = CastSession(
        sourceId: 'client-${Random().nextInt(99999)}',
        destinationId: 'receiver-0');
  }

  // connect to socket
  if (null == await _createSocket()) {
    log.severe('Could not create socket');
    return false;
  }

  _connectionChannel!.sendMessage({'type': 'CONNECT'});

  // start heartbeat
  _heartbeatTick();

  return true;
}