rehandshake method
Force a new handshake without tearing down the transport
Implementation
Future<void> rehandshake({Map<String, String>? headers}) async {
_logger.info('Dispatcher: Starting re-handshake flow');
// Move to connecting state but keep the transport connection
_updateState(2); // connecting
_clientId = null;
try {
await _handshake(headers: headers);
_logger.info('Dispatcher: Re-handshake completed successfully');
_updateState(3); // connected
// Kick off /meta/connect loop immediately
try {
_logger.info('Dispatcher: Initiating /meta/connect after re-handshake');
await sendConnect();
} catch (e) {
_logger.warning(
'Dispatcher: Initial /meta/connect after re-handshake failed: $e');
}
} catch (e) {
_logger.severe('Dispatcher: Re-handshake failed: $e');
_updateState(4); // disconnected
rethrow;
}
}