connect method
Connect to the server. This will reconnect if previously disconnected.
If the connection was manually disconnected via disconnect(), this will restore it.
All subscriptions will be automatically re-registered.
Example:
// Reconnect after being disconnected
await transmit.connect();
Implementation
Future<void> connect() async {
if (_isClosed) {
print('Transmit is closed, cannot connect');
return;
}
if (!_isManuallyDisconnected) {
// Already connected or connecting, no need to do anything
return;
}
_isManuallyDisconnected = false;
// Reset reconnect attempts for fresh start
_reconnectAttempts = 0;
_isReconnecting = false;
_nextRetryTime = null;
// Connect immediately
await _connect();
}