dispose method
Closes the socket, cancels reconnect and ping timers, closes all broadcast controllers, and releases resources.
Safe to call multiple times.
Implementation
@override
void dispose() {
if (_isDisposed) return;
_isDisposed = true;
_reconnectTimer?.cancel();
_reconnectTimer = null;
_stopPingTimer();
_cleanupSocket(close: true);
for (final ctrl in _channelControllers.values) {
ctrl.close();
}
_channelControllers.clear();
_channelStreams.clear();
for (final ctrl in _presenceControllers.values) {
ctrl.close();
}
_presenceControllers.clear();
_presenceStreams.clear();
_desiredSubscriptions.clear();
_desiredPresenceJoins.clear();
_presenceStore.clear();
_updateState(RealtimeConnectionState.disconnected);
_stateController.close();
}