Skip to content

Commit 6a06365

Browse files
committed
fix: making sure reconnecting state goes to offline state once attempts are exhausted
1 parent 47444a1 commit 6a06365

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Assets/Scripts/Gameplay/ConnectionManagement/ConnectionState/ReconnectingConnectionState.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public override void Exit()
4545
{
4646
m_ConnectionManager.StopCoroutine(m_ReconnectCoroutine);
4747
m_ReconnectCoroutine = null;
48-
m_ReconnectMessagePublisher.Publish(new ReconnectMessage(k_NbReconnectAttempts, k_NbReconnectAttempts));
4948
}
49+
m_ReconnectMessagePublisher.Publish(new ReconnectMessage(k_NbReconnectAttempts, k_NbReconnectAttempts));
5050
}
5151

5252
public override void OnClientConnected(ulong clientId)
@@ -64,7 +64,14 @@ public override void OnClientDisconnect(ulong clientId)
6464
m_ConnectionManager.ChangeState(ConnectionStateType.Offline);
6565
break;
6666
default:
67-
m_ReconnectCoroutine = m_ConnectionManager.StartCoroutine(ReconnectCoroutine());
67+
if (m_NbAttempts < k_NbReconnectAttempts)
68+
{
69+
m_ReconnectCoroutine = m_ConnectionManager.StartCoroutine(ReconnectCoroutine());
70+
}
71+
else
72+
{
73+
m_ConnectionManager.ChangeState(ConnectionStateType.Offline);
74+
}
6875
break;
6976
}
7077
}

0 commit comments

Comments
 (0)