Added support for mirror 41
This commit is contained in:
parent
f988f2d8de
commit
cfbfd90fec
5 changed files with 75 additions and 5 deletions
|
|
@ -107,12 +107,20 @@ public class LRMDirectConnectModule : MonoBehaviour
|
||||||
|
|
||||||
public void ServerSend(int clientID, ArraySegment<byte> data, int channel)
|
public void ServerSend(int clientID, ArraySegment<byte> data, int channel)
|
||||||
{
|
{
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
directConnectTransport.ServerSend(clientID, data, channel);
|
||||||
|
#else
|
||||||
directConnectTransport.ServerSend(clientID, channel, data);
|
directConnectTransport.ServerSend(clientID, channel, data);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClientSend(ArraySegment<byte> data, int channel)
|
public void ClientSend(ArraySegment<byte> data, int channel)
|
||||||
{
|
{
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
directConnectTransport.ClientSend(data, channel);
|
||||||
|
#else
|
||||||
directConnectTransport.ClientSend(channel, data);
|
directConnectTransport.ClientSend(channel, data);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Transport Callbacks
|
#region Transport Callbacks
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,11 @@ namespace LightReflectiveMirror
|
||||||
|
|
||||||
_isClient = true;
|
_isClient = true;
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new System.ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new System.ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new System.ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_clientProxy != null)
|
if (_clientProxy != null)
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,11 @@ namespace LightReflectiveMirror
|
||||||
}
|
}
|
||||||
|
|
||||||
_isClient = true;
|
_isClient = true;
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new System.ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new System.ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new System.ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -112,14 +115,23 @@ namespace LightReflectiveMirror
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.LeaveRoom);
|
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.LeaveRoom);
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_directConnectModule != null)
|
if (_directConnectModule != null)
|
||||||
_directConnectModule.ClientDisconnect();
|
_directConnectModule.ClientDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
public override void ClientSend(ArraySegment<byte> segment, int channelId)
|
||||||
|
#else
|
||||||
public override void ClientSend(int channelId, ArraySegment<byte> segment)
|
public override void ClientSend(int channelId, ArraySegment<byte> segment)
|
||||||
|
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (_directConnected)
|
if (_directConnected)
|
||||||
{
|
{
|
||||||
|
|
@ -131,8 +143,11 @@ namespace LightReflectiveMirror
|
||||||
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.SendData);
|
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.SendData);
|
||||||
_clientSendBuffer.WriteBytes(ref pos, segment.Array.Take(segment.Count).ToArray());
|
_clientSendBuffer.WriteBytes(ref pos, segment.Array.Take(segment.Count).ToArray());
|
||||||
_clientSendBuffer.WriteInt(ref pos, 0);
|
_clientSendBuffer.WriteInt(ref pos, 0);
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), channelId);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(channelId, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(channelId, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,7 +183,11 @@ namespace LightReflectiveMirror
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
public override void ServerSend(int connectionId, ArraySegment<byte> segment, int channelId)
|
||||||
|
#else
|
||||||
public override void ServerSend(int connectionId, int channelId, ArraySegment<byte> segment)
|
public override void ServerSend(int connectionId, int channelId, ArraySegment<byte> segment)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (_directConnectModule != null && _connectedDirectClients.TryGetBySecond(connectionId, out int directId))
|
if (_directConnectModule != null && _connectedDirectClients.TryGetBySecond(connectionId, out int directId))
|
||||||
{
|
{
|
||||||
|
|
@ -180,8 +199,11 @@ namespace LightReflectiveMirror
|
||||||
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.SendData);
|
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.SendData);
|
||||||
_clientSendBuffer.WriteBytes(ref pos, segment.Array.Take(segment.Count).ToArray());
|
_clientSendBuffer.WriteBytes(ref pos, segment.Array.Take(segment.Count).ToArray());
|
||||||
_clientSendBuffer.WriteInt(ref pos, _connectedRelayClients.GetBySecond(connectionId));
|
_clientSendBuffer.WriteInt(ref pos, _connectedRelayClients.GetBySecond(connectionId));
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), channelId);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(channelId, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(channelId, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,8 +262,11 @@ namespace LightReflectiveMirror
|
||||||
_clientSendBuffer.WriteBool(ref pos, false);
|
_clientSendBuffer.WriteBool(ref pos, false);
|
||||||
_clientSendBuffer.WriteInt(ref pos, _directConnectModule == null ? 1 : _directConnectModule.SupportsNATPunch() ? _directConnectModule.GetTransportPort() : 1);
|
_clientSendBuffer.WriteInt(ref pos, _directConnectModule == null ? 1 : _directConnectModule.SupportsNATPunch() ? _directConnectModule.GetTransportPort() : 1);
|
||||||
}
|
}
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ServerStop()
|
public override void ServerStop()
|
||||||
|
|
@ -252,7 +277,11 @@ namespace LightReflectiveMirror
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.LeaveRoom);
|
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.LeaveRoom);
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_directConnectModule != null)
|
if (_directConnectModule != null)
|
||||||
_directConnectModule.StopServer();
|
_directConnectModule.StopServer();
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,11 @@ namespace LightReflectiveMirror
|
||||||
|
|
||||||
_isClient = true;
|
_isClient = true;
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new System.ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new System.ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new System.ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator GetServerList(LRMRegions region)
|
IEnumerator GetServerList(LRMRegions region)
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,12 @@ namespace LightReflectiveMirror
|
||||||
// Send a blank message with just the opcode 200, which is heartbeat
|
// Send a blank message with just the opcode 200, which is heartbeat
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
_clientSendBuffer.WriteByte(ref pos, 200);
|
_clientSendBuffer.WriteByte(ref pos, 200);
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
|
|
||||||
// If NAT Puncher is initialized, send heartbeat on that as well.
|
// If NAT Puncher is initialized, send heartbeat on that as well.
|
||||||
|
|
||||||
|
|
@ -339,7 +344,11 @@ namespace LightReflectiveMirror
|
||||||
_clientSendBuffer.WriteBool(ref pos, false);
|
_clientSendBuffer.WriteBool(ref pos, false);
|
||||||
_clientSendBuffer.WriteBool(ref pos, false);
|
_clientSendBuffer.WriteBool(ref pos, false);
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -355,8 +364,11 @@ namespace LightReflectiveMirror
|
||||||
_clientSendBuffer.WriteString(ref pos, newServerData);
|
_clientSendBuffer.WriteString(ref pos, newServerData);
|
||||||
_clientSendBuffer.WriteBool(ref pos, false);
|
_clientSendBuffer.WriteBool(ref pos, false);
|
||||||
_clientSendBuffer.WriteBool(ref pos, false);
|
_clientSendBuffer.WriteBool(ref pos, false);
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -373,7 +385,11 @@ namespace LightReflectiveMirror
|
||||||
_clientSendBuffer.WriteBool(ref pos, isPublic);
|
_clientSendBuffer.WriteBool(ref pos, isPublic);
|
||||||
_clientSendBuffer.WriteBool(ref pos, false);
|
_clientSendBuffer.WriteBool(ref pos, false);
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -390,7 +406,11 @@ namespace LightReflectiveMirror
|
||||||
_clientSendBuffer.WriteBool(ref pos, true);
|
_clientSendBuffer.WriteBool(ref pos, true);
|
||||||
_clientSendBuffer.WriteInt(ref pos, maxPlayers);
|
_clientSendBuffer.WriteInt(ref pos, maxPlayers);
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -410,7 +430,12 @@ namespace LightReflectiveMirror
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.AuthenticationResponse);
|
_clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.AuthenticationResponse);
|
||||||
_clientSendBuffer.WriteString(ref pos, authenticationKey);
|
_clientSendBuffer.WriteString(ref pos, authenticationKey);
|
||||||
|
|
||||||
|
#if MIRROR_40_0_OR_NEWER
|
||||||
|
clientToServerTransport.ClientSend(new ArraySegment<byte>(_clientSendBuffer, 0, pos), 0);
|
||||||
|
#else
|
||||||
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
clientToServerTransport.ClientSend(0, new ArraySegment<byte>(_clientSendBuffer, 0, pos));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum OpCodes
|
public enum OpCodes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue