closeWebSocket method
void
closeWebSocket()
Closes the WebSocket connection and all subscriptions.
This should be called when you are done using the WebSocket to free resources.
Implementation
void closeWebSocket() {
_subscriptions.forEach((key, subscription) {
subscription.cancel();
});
_subscriptions.clear();
_streamController?.close();
_channel?.sink.close();
_channel = null;
debugPrint("🚪 WebSocket and all subscriptions closed.");
}