Skip to content

Commit 7481deb

Browse files
committed
feat: Exposed DisconnectClient on NetworkingManager
1 parent 8e15dcf commit 7481deb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

MLAPI/Core/NetworkingManager.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using MLAPI.Serialization.Pooled;
2424
using MLAPI.Spawning;
2525
using static MLAPI.Messaging.CustomMessagingManager;
26+
using MLAPI.Exceptions;
2627

2728
namespace MLAPI
2829
{
@@ -781,7 +782,7 @@ internal void UpdateNetworkTime(ulong clientId, float netTime, float receiveTime
781782
if (LogHelper.CurrentLogLevel <= LogLevel.Developer) LogHelper.LogInfo($"Received network time {netTime}, RTT to server is {rtt}, setting offset to {networkTimeOffset} (delta {networkTimeOffset - currentNetworkTimeOffset})");
782783
}
783784

784-
internal void SendConnectionRequest()
785+
internal void SendConnectionRequest()
785786
{
786787
using (PooledBitStream stream = PooledBitStream.Get())
787788
{
@@ -944,10 +945,16 @@ private void HandleIncomingData(ulong clientId, string channelName, ArraySegment
944945
}
945946
}
946947

947-
internal void DisconnectClient(ulong clientId)
948+
/// <summary>
949+
/// Disconnects the remote client.
950+
/// </summary>
951+
/// <param name="clientId">The ClientId to disconnect</param>
952+
public void DisconnectClient(ulong clientId)
948953
{
949954
if (!IsServer)
950-
return;
955+
{
956+
throw new NotServerException("Only server can disconnect remote clients. Use StopClient instead.");
957+
}
951958

952959
if (ConnectedClients.ContainsKey(clientId))
953960
ConnectedClients.Remove(clientId);

0 commit comments

Comments
 (0)