@@ -109,36 +109,21 @@ IEnumerator ReconnectCoroutine()
109
109
Debug . Log ( $ "Reconnecting attempt { m_NbAttempts + 1 } /{ m_ConnectionManager . NbReconnectAttempts } ...") ;
110
110
m_ReconnectMessagePublisher . Publish ( new ReconnectMessage ( m_NbAttempts , m_ConnectionManager . NbReconnectAttempts ) ) ;
111
111
m_NbAttempts ++ ;
112
- if ( m_LobbyServiceFacade . CurrentUnityLobby != null ) // Attempting to reconnect to lobby.
113
- {
114
- // When using Lobby with Relay, if a user is disconnected from the Relay server, the server will notify
115
- // the Lobby service and mark the user as disconnected, but will not remove them from the lobby. They
116
- // then have some time to attempt to reconnect (defined by the "Disconnect removal time" parameter on
117
- // the dashboard), after which they will be removed from the lobby completely.
118
- // See https://docs.unity.com/lobby/reconnect-to-lobby.html
119
- var reconnectingToLobby = m_LobbyServiceFacade . ReconnectToLobbyAsync ( ) ;
120
- yield return new WaitUntil ( ( ) => reconnectingToLobby . IsCompleted ) ;
112
+ var reconnectingSetupTask = m_ConnectionMethod . SetupClientReconnectionAsync ( ) ;
113
+ yield return new WaitUntil ( ( ) => reconnectingSetupTask . IsCompleted ) ;
121
114
122
- // If succeeded, attempt to connect to Relay
123
- if ( ! reconnectingToLobby . IsFaulted && reconnectingToLobby . Result != null )
124
- {
125
- // If this fails, the OnClientDisconnect callback will be invoked by Netcode
126
- var connectingToRelay = ConnectClientAsync ( ) ;
127
- yield return new WaitUntil ( ( ) => connectingToRelay . IsCompleted ) ;
128
- }
129
- else
130
- {
131
- Debug . Log ( "Failed reconnecting to lobby." ) ;
132
- // Calling OnClientDisconnect to mark this attempt as failed and either start a new one or give up
133
- // and return to the Offline state
134
- OnClientDisconnect ( 0 ) ;
135
- }
136
- }
137
- else // If not using Lobby, simply try to reconnect to the server directly
115
+ if ( ! reconnectingSetupTask . IsFaulted && reconnectingSetupTask . Result )
138
116
{
139
117
// If this fails, the OnClientDisconnect callback will be invoked by Netcode
140
- var connectingClient = ConnectClientAsync ( ) ;
141
- yield return new WaitUntil ( ( ) => connectingClient . IsCompleted ) ;
118
+ var connectingToRelay = ConnectClientAsync ( ) ;
119
+ yield return new WaitUntil ( ( ) => connectingToRelay . IsCompleted ) ;
120
+ }
121
+ else
122
+ {
123
+ Debug . Log ( "Failed reconnecting to lobby." ) ;
124
+ // Calling OnClientDisconnect to mark this attempt as failed and either start a new one or give up
125
+ // and return to the Offline state
126
+ OnClientDisconnect ( 0 ) ;
142
127
}
143
128
}
144
129
}
0 commit comments