@@ -27,28 +27,21 @@ public override void Exit() { }
27
27
28
28
public override void OnClientDisconnect ( ulong clientId )
29
29
{
30
- // This is also called on the Host when a different client disconnects. To make sure we only handle our own disconnection, verify that we are either
31
- // not a host (in which case we know this is about us) or that the clientID is the same as ours if we are the host.
32
- if ( ! NetworkManager . Singleton . IsHost || NetworkManager . Singleton . IsHost && NetworkManager . Singleton . LocalClientId == clientId )
30
+ switch ( m_ConnectionManager . DisconnectReason . Reason )
33
31
{
34
- //On a client disconnect we want to take them back to the main menu.
35
- //We have to check here in SceneManager if our active scene is the main menu, as if it is, it means we timed out rather than a raw disconnect;
36
- switch ( m_ConnectionManager . DisconnectReason . Reason )
37
- {
38
- case ConnectStatus . UserRequestedDisconnect :
39
- case ConnectStatus . HostEndedSession :
40
- m_QuitGameSessionPublisher . Publish ( new QuitGameSessionMessage ( ) { UserRequested = false } ) ; // go through the normal leave flow
41
- m_ConnectionManager . ChangeState ( ConnectionStateType . Offline ) ;
42
- break ;
43
- default :
44
- // try reconnecting
45
- m_ConnectionManager . ChangeState ( ConnectionStateType . Reconnecting ) ;
46
- break ;
47
- }
48
-
49
- m_ConnectStatusPublisher . Publish ( m_ConnectionManager . DisconnectReason . Reason ) ;
50
- m_ConnectionManager . DisconnectReason . Clear ( ) ;
32
+ case ConnectStatus . UserRequestedDisconnect :
33
+ case ConnectStatus . HostEndedSession :
34
+ m_QuitGameSessionPublisher . Publish ( new QuitGameSessionMessage ( ) { UserRequested = false } ) ; // go through the normal leave flow
35
+ m_ConnectionManager . ChangeState ( ConnectionStateType . Offline ) ;
36
+ break ;
37
+ default :
38
+ // try reconnecting
39
+ m_ConnectionManager . ChangeState ( ConnectionStateType . Reconnecting ) ;
40
+ break ;
51
41
}
42
+
43
+ m_ConnectStatusPublisher . Publish ( m_ConnectionManager . DisconnectReason . Reason ) ;
44
+ m_ConnectionManager . DisconnectReason . Clear ( ) ;
52
45
}
53
46
54
47
public override void OnUserRequestedShutdown ( )
0 commit comments