From 68ad56478599d6cd1f460715880154169f1766ad Mon Sep 17 00:00:00 2001 From: Derek S <44935661+Derek-R-S@users.noreply.github.com> Date: Tue, 18 May 2021 13:21:29 -0500 Subject: [PATCH] Support for mirror 37.0 --- .../Transport/LRM/LRMDirectConnectModule.cs | 9 +++++++-- .../LRM/LRMTransport/LRMTransportOverrides.cs | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMDirectConnectModule.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMDirectConnectModule.cs index 53fd576d..dd7b6b38 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMDirectConnectModule.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMDirectConnectModule.cs @@ -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() @@ -110,7 +115,7 @@ public void ClientSend(ArraySegment data, int channel) directConnectTransport.ClientSend(channel, data); } - #region Transport Callbacks +#region Transport Callbacks void OnServerConnected(int clientID) { if (showDebugLogs) @@ -157,5 +162,5 @@ void OnClientError(Exception error) if (showDebugLogs) Debug.Log("Direct Client Error: " + error); } - #endregion +#endregion } \ No newline at end of file diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs index 2ef59bd6..aa2ed656 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs @@ -136,6 +136,21 @@ public override void ClientSend(int channelId, ArraySegment 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)) @@ -151,6 +166,7 @@ public override bool ServerDisconnect(int connectionId) return false; } +#endif public override void ServerSend(int connectionId, int channelId, ArraySegment segment) {