Skip to content

Commit c7dd950

Browse files
committed
Added onClientConnect callback & isClinetConnected bool to NetManager
1 parent 5f0eeab commit c7dd950

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public bool isHost
4242
private byte[] messageBuffer;
4343
internal int serverClientId;
4444

45+
public bool IsClientConnected;
46+
public Action OnClientConnectedCallback = null;
4547

4648
public NetworkingConfiguration NetworkConfig;
4749

@@ -337,6 +339,10 @@ private void Update()
337339
OnClientDisconnect(clientId);
338340
return;
339341
}
342+
else
343+
{
344+
IsClientConnected = false;
345+
}
340346
}
341347
else if (networkError != NetworkError.Ok)
342348
{
@@ -379,6 +385,8 @@ private void Update()
379385
case NetworkEventType.DisconnectEvent:
380386
if (isServer)
381387
OnClientDisconnect(clientId);
388+
else
389+
IsClientConnected = false;
382390
break;
383391
}
384392
// 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)
@@ -591,6 +599,9 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
591599
}
592600
}
593601
}
602+
if (OnClientConnectedCallback != null)
603+
OnClientConnectedCallback.Invoke();
604+
IsClientConnected = true;
594605
}
595606
break;
596607
case 2:

0 commit comments

Comments
 (0)