This commit is contained in:
Derek 2021-01-16 16:51:12 -06:00
parent af5e74f36a
commit 5e1b43bb06
4 changed files with 23 additions and 13 deletions

View file

@ -67,11 +67,11 @@ UpdateHeartbeatInterval - the amounts of update calls before sending a heartbeat
## Example ## Example
No Example yet! Maqsoom's Server List Example - https://github.com/maqsoom/LightReflectiveMirror-Example
## Credits ## 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! All Mirror Transport Creators! - They made all the transports that this thing relies on! Especially the Simple Web Transport by default!

View file

@ -78,11 +78,10 @@ namespace LightReflectiveMirror
SendServerList(clientId); SendServerList(clientId);
break; break;
case OpCodes.UpdateRoomData: case OpCodes.UpdateRoomData:
var room = GetRoomForPlayer(clientId); var plyRoom = GetRoomForPlayer(clientId);
if (room == null)
return;
var plyRoom = room.Value; if (plyRoom == null)
return;
bool newName = data.ReadBool(ref pos); bool newName = data.ReadBool(ref pos);
if (newName) if (newName)
@ -138,11 +137,11 @@ namespace LightReflectiveMirror
void ProcessData(int clientId, byte[] clientData, int channel, int sendTo = -1) void ProcessData(int clientId, byte[] clientData, int channel, int sendTo = -1)
{ {
Room? playersRoom = GetRoomForPlayer(clientId); Room playersRoom = GetRoomForPlayer(clientId);
if(playersRoom != null) if(playersRoom != null)
{ {
Room room = playersRoom.Value; Room room = playersRoom;
if(room.hostId == clientId) 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++) for(int i = 0; i < rooms.Count; i++)
{ {

View file

@ -4,7 +4,7 @@ using System.Text;
namespace LightReflectiveMirror namespace LightReflectiveMirror
{ {
struct Room class Room
{ {
public int hostId; public int hostId;
public string serverName; public string serverName;

View file

@ -12,7 +12,7 @@ namespace LightReflectiveMirror
{ {
[Header("Connection Variables")] [Header("Connection Variables")]
public Transport clientToServerTransport; public Transport clientToServerTransport;
public string serverIP; public string serverIP = "34.67.125.123";
public float heartBeatInterval = 3; public float heartBeatInterval = 3;
public bool connectOnAwake = true; public bool connectOnAwake = true;
public string authenticationKey = "Secret Auth Key"; public string authenticationKey = "Secret Auth Key";
@ -168,29 +168,40 @@ namespace LightReflectiveMirror
if (_isServer) if (_isServer)
{ {
int pos = 0; int pos = 0;
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.UpdateRoomData);
if (!string.IsNullOrEmpty(newServerName)) if (!string.IsNullOrEmpty(newServerName))
{ {
_clientSendBuffer.WriteBool(ref pos, true); _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)) if (!string.IsNullOrEmpty(newServerData))
{ {
_clientSendBuffer.WriteBool(ref pos, true); _clientSendBuffer.WriteBool(ref pos, true);
_clientSendBuffer.WriteString(ref pos, newServerData); _clientSendBuffer.WriteString(ref pos, newServerData);
} }
else
_clientSendBuffer.WriteBool(ref pos, false);
if (newServerIsPublic != null) if (newServerIsPublic != null)
{ {
_clientSendBuffer.WriteBool(ref pos, true); _clientSendBuffer.WriteBool(ref pos, true);
_clientSendBuffer.WriteBool(ref pos, newServerIsPublic.Value); _clientSendBuffer.WriteBool(ref pos, newServerIsPublic.Value);
} }
else
_clientSendBuffer.WriteBool(ref pos, false);
if (newPlayerCap != null) if (newPlayerCap != null)
{ {
_clientSendBuffer.WriteBool(ref pos, true); _clientSendBuffer.WriteBool(ref pos, true);
_clientSendBuffer.WriteInt(ref pos, newPlayerCap.Value); _clientSendBuffer.WriteInt(ref pos, newPlayerCap.Value);
} }
else
_clientSendBuffer.WriteBool(ref pos, false);
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos)); clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
} }