server ID to strings (Unity Side)
This commit is contained in:
parent
0916cb66a9
commit
89c1018fbf
5 changed files with 12 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<int> clients;
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Reference in a new issue