diff --git a/README.md b/README.md index a80ab17..28dfb00 100644 --- a/README.md +++ b/README.md @@ -67,11 +67,11 @@ UpdateHeartbeatInterval - the amounts of update calls before sending a heartbeat ## Example -No Example yet! +Maqsoom's Server List Example - https://github.com/maqsoom/LightReflectiveMirror-Example ## Credits -Maqsoom & JesusLuvsYooh - Both really active testers and have been testing it since I pitched the idea. They tested almost all versions of DRM and I assume they will test the crap out of LRM! +Maqsoom & JesusLuvsYooh - Both really active testers and have been testing it since I pitched the idea. They tested almost all versions of DRM and I am sure they will test the crap out of LRM! All Mirror Transport Creators! - They made all the transports that this thing relies on! Especially the Simple Web Transport by default! diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/RelayHandler.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/RelayHandler.cs index 80b2a01..6cd53cc 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/RelayHandler.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/RelayHandler.cs @@ -78,11 +78,10 @@ namespace LightReflectiveMirror SendServerList(clientId); break; case OpCodes.UpdateRoomData: - var room = GetRoomForPlayer(clientId); - if (room == null) - return; + var plyRoom = GetRoomForPlayer(clientId); - var plyRoom = room.Value; + if (plyRoom == null) + return; bool newName = data.ReadBool(ref pos); if (newName) @@ -99,7 +98,7 @@ namespace LightReflectiveMirror bool newPlayerCap = data.ReadBool(ref pos); if (newPlayerCap) plyRoom.maxPlayers = data.ReadInt(ref pos); - + break; } } @@ -138,11 +137,11 @@ namespace LightReflectiveMirror void ProcessData(int clientId, byte[] clientData, int channel, int sendTo = -1) { - Room? playersRoom = GetRoomForPlayer(clientId); + Room playersRoom = GetRoomForPlayer(clientId); if(playersRoom != null) { - Room room = playersRoom.Value; + Room room = playersRoom; if(room.hostId == clientId) { @@ -174,7 +173,7 @@ namespace LightReflectiveMirror } } - Room? GetRoomForPlayer(int clientId) + Room GetRoomForPlayer(int clientId) { for(int i = 0; i < rooms.Count; i++) { diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs index d77ae68..06386e4 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs @@ -4,7 +4,7 @@ using System.Text; namespace LightReflectiveMirror { - struct Room + class Room { public int hostId; public string serverName; diff --git a/UnityTransport/LightReflectiveMirrorTransport.cs b/UnityTransport/LightReflectiveMirrorTransport.cs index 53d2f21..90657fd 100644 --- a/UnityTransport/LightReflectiveMirrorTransport.cs +++ b/UnityTransport/LightReflectiveMirrorTransport.cs @@ -12,7 +12,7 @@ namespace LightReflectiveMirror { [Header("Connection Variables")] public Transport clientToServerTransport; - public string serverIP; + public string serverIP = "34.67.125.123"; public float heartBeatInterval = 3; public bool connectOnAwake = true; public string authenticationKey = "Secret Auth Key"; @@ -168,29 +168,40 @@ namespace LightReflectiveMirror if (_isServer) { int pos = 0; + + _clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.UpdateRoomData); + if (!string.IsNullOrEmpty(newServerName)) { _clientSendBuffer.WriteBool(ref pos, true); - _clientSendBuffer.WriteString(ref pos,newServerName); + _clientSendBuffer.WriteString(ref pos, newServerName); } + else + _clientSendBuffer.WriteBool(ref pos, false); if (!string.IsNullOrEmpty(newServerData)) { _clientSendBuffer.WriteBool(ref pos, true); _clientSendBuffer.WriteString(ref pos, newServerData); } + else + _clientSendBuffer.WriteBool(ref pos, false); if (newServerIsPublic != null) { _clientSendBuffer.WriteBool(ref pos, true); _clientSendBuffer.WriteBool(ref pos, newServerIsPublic.Value); } + else + _clientSendBuffer.WriteBool(ref pos, false); if (newPlayerCap != null) { _clientSendBuffer.WriteBool(ref pos, true); _clientSendBuffer.WriteInt(ref pos, newPlayerCap.Value); } + else + _clientSendBuffer.WriteBool(ref pos, false); clientToServerTransport.ClientSend(0, new ArraySegment(_clientSendBuffer, 0, pos)); }