feat: Enhance connection handling and add debug logs feature; improve user experience and troubleshooting
This commit is contained in:
@@ -194,6 +194,18 @@ class Protocol(
|
||||
val currentState = _state.value
|
||||
log("🔌 CONNECT CALLED: currentState=$currentState, reconnectAttempts=$reconnectAttempts, isConnecting=$isConnecting")
|
||||
|
||||
// КРИТИЧНО: Если уже подключены и аутентифицированы - не переподключаемся!
|
||||
if (currentState == ProtocolState.AUTHENTICATED || currentState == ProtocolState.HANDSHAKING) {
|
||||
log("✅ Already authenticated or handshaking, skipping connect()")
|
||||
return
|
||||
}
|
||||
|
||||
// КРИТИЧНО: Если уже CONNECTED и есть credentials - тоже пропускаем
|
||||
if (currentState == ProtocolState.CONNECTED && webSocket != null) {
|
||||
log("✅ Already connected with valid socket, skipping connect()")
|
||||
return
|
||||
}
|
||||
|
||||
// КРИТИЧНО: проверяем флаг isConnecting, а не только состояние
|
||||
if (isConnecting || currentState == ProtocolState.CONNECTING) {
|
||||
log("⚠️ Already connecting, skipping... (preventing duplicate connect)")
|
||||
|
||||
Reference in New Issue
Block a user