Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Commit

Permalink
Support for mirror 37.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek-R-S committed May 18, 2021
1 parent c3558be commit 68ad564
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ public bool KickClient(int clientID)
{
if (showDebugLogs)
Debug.Log("Kicked direct connect client.");
#if MIRROR_37_0_OR_NEWER
directConnectTransport.ServerDisconnect(clientID);
return true;
#else
return directConnectTransport.ServerDisconnect(clientID);
#endif
}

public void ClientDisconnect()
Expand All @@ -110,7 +115,7 @@ public void ClientSend(ArraySegment<byte> data, int channel)
directConnectTransport.ClientSend(channel, data);
}

#region Transport Callbacks
#region Transport Callbacks
void OnServerConnected(int clientID)
{
if (showDebugLogs)
Expand Down Expand Up @@ -157,5 +162,5 @@ void OnClientError(Exception error)
if (showDebugLogs)
Debug.Log("Direct Client Error: " + error);
}
#endregion
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ public override void ClientSend(int channelId, ArraySegment<byte> segment)
}
}

#if MIRROR_37_0_OR_NEWER
public override void ServerDisconnect(int connectionId)
{
if (_connectedRelayClients.TryGetBySecond(connectionId, out int relayId))
{
int pos = 0;
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.KickPlayer);
_clientSendBuffer.WriteInt(ref pos, relayId);
return;
}

if (_connectedDirectClients.TryGetBySecond(connectionId, out int directId))
_directConnectModule.KickClient(directId);
}
#else
public override bool ServerDisconnect(int connectionId)
{
if (_connectedRelayClients.TryGetBySecond(connectionId, out int relayId))
Expand All @@ -151,6 +166,7 @@ public override bool ServerDisconnect(int connectionId)

return false;
}
#endif

public override void ServerSend(int connectionId, int channelId, ArraySegment<byte> segment)
{
Expand Down

0 comments on commit 68ad564

Please sign in to comment.