sendConnect method

Future<void> sendConnect()

Send connect message

Implementation

Future<void> sendConnect() async {
  _logger.info('Dispatcher: Sending connect message');
  _logger.info('Dispatcher: Current state: $_state, clientId: $_clientId');

  if (_state != 3 || _clientId == null) {
    // connected
    _logger.severe(
        'Dispatcher: Cannot send connect - not connected or no clientId. State: $_state, clientId: $_clientId');
    throw FayeError.network('Not connected');
  }

  final message = {
    'channel': '/meta/connect',
    'clientId': _clientId,
    'connectionType':
        _transport != null ? _toBayeuxType(_transport!.name) : 'long-polling',
    'ext': <String, dynamic>{}, // Required for session maintenance
  };

  _logger.info('Dispatcher: Sending connect message: $message');
  await _sendMessage(message);
}