From 0622ca7a371ca300cb7a348c2fd81672b8f27066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com> Date: Wed, 28 Mar 2018 17:34:42 +0200 Subject: [PATCH] Added callback for when client disconnects --- MLAPI/MonoBehaviours/Core/NetworkingManager.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs index a286a1b..08029b4 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs @@ -44,6 +44,7 @@ namespace MLAPI public bool IsClientConnected; public Action OnClientConnectedCallback = null; + public Action OnClientDisconnectCallback = null; public NetworkingConfiguration NetworkConfig; @@ -341,6 +342,8 @@ namespace MLAPI } else { + if (OnClientDisconnectCallback != null) + OnClientDisconnectCallback.Invoke(); IsClientConnected = false; } } @@ -386,7 +389,12 @@ namespace MLAPI if (isServer) OnClientDisconnect(clientId); else + { + if (OnClientDisconnectCallback != null) + OnClientDisconnectCallback.Invoke(); + IsClientConnected = false; + } break; } // Only do another iteration if: there are no more messages AND (there is no limit to max events or we have processed less than the maximum)