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)
|
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();
|
OnClientDisconnected?.Invoke();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -68,14 +68,14 @@ namespace LightReflectiveMirror
|
||||||
if (_isClient || _isServer)
|
if (_isClient || _isServer)
|
||||||
throw new Exception("Cannot connect while hosting/already connected!");
|
throw new Exception("Cannot connect while hosting/already connected!");
|
||||||
|
|
||||||
var room = GetServerForID(_cachedHostID);
|
var room = GetServerForID(address);
|
||||||
|
|
||||||
if (!useLoadBalancer || room.relayInfo.Address == serverIP)
|
if (!useLoadBalancer || room.relayInfo.Address == serverIP)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
_directConnected = false;
|
_directConnected = false;
|
||||||
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.JoinServer);
|
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.JoinServer);
|
||||||
_clientSendBuffer.WriteInt(ref pos, _cachedHostID);
|
_clientSendBuffer.WriteString(ref pos, address);
|
||||||
_clientSendBuffer.WriteBool(ref pos, _directConnectModule != null);
|
_clientSendBuffer.WriteBool(ref pos, _directConnectModule != null);
|
||||||
|
|
||||||
if (GetLocalIp() == null)
|
if (GetLocalIp() == null)
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace LightReflectiveMirror
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
_directConnected = false;
|
_directConnected = false;
|
||||||
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.JoinServer);
|
_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);
|
_clientSendBuffer.WriteBool(ref pos, _directConnectModule != null);
|
||||||
|
|
||||||
if (GetLocalIp() == null)
|
if (GetLocalIp() == null)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace LightReflectiveMirror
|
||||||
|
|
||||||
// Current Server Information
|
// Current Server Information
|
||||||
public string serverStatus = "Not Started.";
|
public string serverStatus = "Not Started.";
|
||||||
public int serverId = -1;
|
public string serverId = string.Empty;
|
||||||
|
|
||||||
private LRMDirectConnectModule _directConnectModule;
|
private LRMDirectConnectModule _directConnectModule;
|
||||||
|
|
||||||
|
|
@ -50,7 +50,6 @@ namespace LightReflectiveMirror
|
||||||
private bool _isAuthenticated = false;
|
private bool _isAuthenticated = false;
|
||||||
private int _currentMemberId;
|
private int _currentMemberId;
|
||||||
private bool _callbacksInitialized = false;
|
private bool _callbacksInitialized = false;
|
||||||
private int _cachedHostID;
|
|
||||||
private UdpClient _NATPuncher;
|
private UdpClient _NATPuncher;
|
||||||
private IPEndPoint _NATIP;
|
private IPEndPoint _NATIP;
|
||||||
private IPEndPoint _relayPuncherIP;
|
private IPEndPoint _relayPuncherIP;
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ namespace LightReflectiveMirror
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OpCodes.RoomCreated:
|
case OpCodes.RoomCreated:
|
||||||
serverId = data.ReadInt(ref pos);
|
serverId = data.ReadString(ref pos);
|
||||||
break;
|
break;
|
||||||
case OpCodes.ServerJoined:
|
case OpCodes.ServerJoined:
|
||||||
int clientId = data.ReadInt(ref pos);
|
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++)
|
for(int i = 0; i < relayServerList.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -378,7 +378,7 @@ namespace LightReflectiveMirror
|
||||||
{
|
{
|
||||||
public string serverName;
|
public string serverName;
|
||||||
public int maxPlayers;
|
public int maxPlayers;
|
||||||
public int serverId;
|
public string serverId;
|
||||||
public string serverData;
|
public string serverData;
|
||||||
public int hostId;
|
public int hostId;
|
||||||
public List<int> clients;
|
public List<int> clients;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ GraphicsSettings:
|
||||||
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 10783, 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_PreloadedShaders: []
|
||||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||||
type: 0}
|
type: 0}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue