From 89c1018fbf29b5b0e3094f26866cd53cab9f1068 Mon Sep 17 00:00:00 2001 From: Derek S <44935661+Derek-R-S@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:24:57 -0500 Subject: [PATCH] server ID to strings (Unity Side) --- .../Transport/LRM/LRMTransport/LRMTransportOverrides.cs | 8 ++++---- .../Transport/LRM/LRMTransport/LRMTransportRequests.cs | 2 +- .../Transport/LRM/LRMTransport/LRMTransportVariables.cs | 3 +-- .../LRM/LRMTransport/LightReflectiveMirrorTransport.cs | 6 +++--- UnityProject/ProjectSettings/GraphicsSettings.asset | 3 +++ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs index 37bef12..24cdb5f 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportOverrides.cs @@ -58,9 +58,9 @@ namespace LightReflectiveMirror public override void ClientConnect(string address) { - if (!Available() || !int.TryParse(address, out _cachedHostID)) + if (!Available()) { - Debug.Log("Not connected to relay or invalid server id!"); + Debug.Log("Not connected to relay!"); OnClientDisconnected?.Invoke(); return; } @@ -68,14 +68,14 @@ namespace LightReflectiveMirror if (_isClient || _isServer) throw new Exception("Cannot connect while hosting/already connected!"); - var room = GetServerForID(_cachedHostID); + var room = GetServerForID(address); if (!useLoadBalancer || room.relayInfo.Address == serverIP) { int pos = 0; _directConnected = false; _clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.JoinServer); - _clientSendBuffer.WriteInt(ref pos, _cachedHostID); + _clientSendBuffer.WriteString(ref pos, address); _clientSendBuffer.WriteBool(ref pos, _directConnectModule != null); if (GetLocalIp() == null) diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportRequests.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportRequests.cs index c26d434..453aa55 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportRequests.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportRequests.cs @@ -75,7 +75,7 @@ namespace LightReflectiveMirror int pos = 0; _directConnected = false; _clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.JoinServer); - _clientSendBuffer.WriteInt(ref pos, room.serverId); + _clientSendBuffer.WriteString(ref pos, room.serverId); _clientSendBuffer.WriteBool(ref pos, _directConnectModule != null); if (GetLocalIp() == null) diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportVariables.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportVariables.cs index 1f0a979..f929c00 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportVariables.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LRMTransportVariables.cs @@ -38,7 +38,7 @@ namespace LightReflectiveMirror // Current Server Information public string serverStatus = "Not Started."; - public int serverId = -1; + public string serverId = string.Empty; private LRMDirectConnectModule _directConnectModule; @@ -50,7 +50,6 @@ namespace LightReflectiveMirror private bool _isAuthenticated = false; private int _currentMemberId; private bool _callbacksInitialized = false; - private int _cachedHostID; private UdpClient _NATPuncher; private IPEndPoint _NATIP; private IPEndPoint _relayPuncherIP; diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs index 812d203..ad2a65e 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs @@ -189,7 +189,7 @@ namespace LightReflectiveMirror } break; case OpCodes.RoomCreated: - serverId = data.ReadInt(ref pos); + serverId = data.ReadString(ref pos); break; case OpCodes.ServerJoined: int clientId = data.ReadInt(ref pos); @@ -332,7 +332,7 @@ namespace LightReflectiveMirror } } - Room GetServerForID(int serverID) + Room GetServerForID(string serverID) { for(int i = 0; i < relayServerList.Count; i++) { @@ -378,7 +378,7 @@ namespace LightReflectiveMirror { public string serverName; public int maxPlayers; - public int serverId; + public string serverId; public string serverData; public int hostId; public List clients; diff --git a/UnityProject/ProjectSettings/GraphicsSettings.asset b/UnityProject/ProjectSettings/GraphicsSettings.asset index 35a0fa7..a7bcfc3 100644 --- a/UnityProject/ProjectSettings/GraphicsSettings.asset +++ b/UnityProject/ProjectSettings/GraphicsSettings.asset @@ -36,6 +36,9 @@ GraphicsSettings: - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}