Skip to content

Commit 7cfda6b

Browse files
committed
moved requested netmanger shutdown to server/client gamenetportals
1 parent 8c5a613 commit 7cfda6b

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement/ClientGameNetPortal.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public void OnUserDisconnectRequest()
111111
m_ConnectStatusPub.Publish(DisconnectReason.Reason);
112112
DisconnectReason.Clear();
113113
}
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+
}
114120
}
115121
}
116122

Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement/GameNetPortal.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -247,27 +247,6 @@ public void RequestDisconnect()
247247
}
248248
m_ClientPortal.OnUserDisconnectRequest();
249249
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();
271250
}
272251
}
273252
}

Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement/ServerGameNetPortal.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,18 @@ public void OnUserDisconnectRequest()
109109
if (m_Portal.NetManager.IsServer)
110110
{
111111
SendServerToAllClientsSetDisconnectReason(ConnectStatus.HostDisconnected);
112+
// wait before shutting down to make sure those messages get sent before the clients disconnect.
113+
StartCoroutine(WaitToShutdown());
112114
}
113115
}
114116

117+
IEnumerator WaitToShutdown()
118+
{
119+
yield return new WaitForSeconds(0.5f);
120+
SessionManager<SessionPlayerData>.Instance.OnUserDisconnectRequest();
121+
m_Portal.NetManager.Shutdown();
122+
}
123+
115124
private void Clear()
116125
{
117126
//resets all our runtime state.

0 commit comments

Comments
 (0)