File tree Expand file tree Collapse file tree 3 files changed +15
-21
lines changed
Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement Expand file tree Collapse file tree 3 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,12 @@ public void OnUserDisconnectRequest()
111
111
m_ConnectStatusPub . Publish ( DisconnectReason . Reason ) ;
112
112
DisconnectReason . Clear ( ) ;
113
113
}
114
+
115
+ // only do it here if we are not the host. The host will do it in ServerGameNetPortal
116
+ if ( ! m_Portal . NetManager . IsHost )
117
+ {
118
+ m_Portal . NetManager . Shutdown ( ) ;
119
+ }
114
120
}
115
121
}
116
122
Original file line number Diff line number Diff line change @@ -247,27 +247,6 @@ public void RequestDisconnect()
247
247
}
248
248
m_ClientPortal . OnUserDisconnectRequest ( ) ;
249
249
m_ServerPortal . OnUserDisconnectRequest ( ) ;
250
-
251
- if ( NetManager . IsServer )
252
- {
253
- StartCoroutine ( WaitToShutdown ( ) ) ;
254
- }
255
- else
256
- {
257
- ShutDown ( ) ;
258
- }
259
- }
260
-
261
- void ShutDown ( )
262
- {
263
- SessionManager < SessionPlayerData > . Instance . OnUserDisconnectRequest ( ) ;
264
- NetManager . Shutdown ( ) ;
265
- }
266
-
267
- IEnumerator WaitToShutdown ( )
268
- {
269
- yield return new WaitForSeconds ( 0.5f ) ;
270
- ShutDown ( ) ;
271
250
}
272
251
}
273
252
}
Original file line number Diff line number Diff line change @@ -109,9 +109,18 @@ public void OnUserDisconnectRequest()
109
109
if ( m_Portal . NetManager . IsServer )
110
110
{
111
111
SendServerToAllClientsSetDisconnectReason ( ConnectStatus . HostDisconnected ) ;
112
+ // wait before shutting down to make sure those messages get sent before the clients disconnect.
113
+ StartCoroutine ( WaitToShutdown ( ) ) ;
112
114
}
113
115
}
114
116
117
+ IEnumerator WaitToShutdown ( )
118
+ {
119
+ yield return new WaitForSeconds ( 0.5f ) ;
120
+ SessionManager < SessionPlayerData > . Instance . OnUserDisconnectRequest ( ) ;
121
+ m_Portal . NetManager . Shutdown ( ) ;
122
+ }
123
+
115
124
private void Clear ( )
116
125
{
117
126
//resets all our runtime state.
You can’t perform that action at this time.
0 commit comments