Skip to content

Commit 0622ca7

Browse files
committed
Added callback for when client disconnects
1 parent c7dd950 commit 0622ca7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public bool isHost
4444

4545
public bool IsClientConnected;
4646
public Action OnClientConnectedCallback = null;
47+
public Action OnClientDisconnectCallback = null;
4748

4849
public NetworkingConfiguration NetworkConfig;
4950

@@ -341,6 +342,8 @@ private void Update()
341342
}
342343
else
343344
{
345+
if (OnClientDisconnectCallback != null)
346+
OnClientDisconnectCallback.Invoke();
344347
IsClientConnected = false;
345348
}
346349
}
@@ -386,7 +389,12 @@ private void Update()
386389
if (isServer)
387390
OnClientDisconnect(clientId);
388391
else
392+
{
393+
if (OnClientDisconnectCallback != null)
394+
OnClientDisconnectCallback.Invoke();
395+
389396
IsClientConnected = false;
397+
}
390398
break;
391399
}
392400
// 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)

0 commit comments

Comments
 (0)