2020-12-07 21:19:16 +00:00
|
|
|
|
using QuantumUNET.Messages;
|
|
|
|
|
using UnityEngine;
|
2020-12-02 18:40:38 +00:00
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
2020-12-04 22:14:53 +00:00
|
|
|
|
namespace QuantumUNET
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
2020-12-03 08:28:05 +00:00
|
|
|
|
internal class QSBULocalConnectionToServer : QSBNetworkConnection
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
|
|
|
|
public QSBULocalConnectionToServer(QSBNetworkServer localServer)
|
|
|
|
|
{
|
|
|
|
|
address = "localServer";
|
|
|
|
|
m_LocalServer = localServer;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 09:07:40 +00:00
|
|
|
|
public override bool Send(short msgType, QSBMessageBase msg)
|
|
|
|
|
{
|
|
|
|
|
return m_LocalServer.InvokeHandlerOnServer(this, msgType, msg, 0);
|
|
|
|
|
}
|
2020-12-02 18:40:38 +00:00
|
|
|
|
|
2020-12-16 09:07:40 +00:00
|
|
|
|
public override bool SendUnreliable(short msgType, QSBMessageBase msg)
|
|
|
|
|
{
|
|
|
|
|
return m_LocalServer.InvokeHandlerOnServer(this, msgType, msg, 1);
|
|
|
|
|
}
|
2020-12-02 18:40:38 +00:00
|
|
|
|
|
2020-12-16 09:07:40 +00:00
|
|
|
|
public override bool SendByChannel(short msgType, QSBMessageBase msg, int channelId)
|
|
|
|
|
{
|
|
|
|
|
return m_LocalServer.InvokeHandlerOnServer(this, msgType, msg, channelId);
|
|
|
|
|
}
|
2020-12-02 18:40:38 +00:00
|
|
|
|
|
|
|
|
|
public override bool SendBytes(byte[] bytes, int numBytes, int channelId)
|
|
|
|
|
{
|
|
|
|
|
bool result;
|
|
|
|
|
if (numBytes <= 0)
|
|
|
|
|
{
|
|
|
|
|
if (LogFilter.logError)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("LocalConnection:SendBytes cannot send zero bytes");
|
|
|
|
|
}
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = m_LocalServer.InvokeBytes(this, bytes, numBytes, channelId);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 09:07:40 +00:00
|
|
|
|
public override bool SendWriter(QSBNetworkWriter writer, int channelId)
|
|
|
|
|
{
|
|
|
|
|
return m_LocalServer.InvokeBytes(this, writer.AsArray(), (int)((short)writer.AsArray().Length), channelId);
|
|
|
|
|
}
|
2020-12-02 18:40:38 +00:00
|
|
|
|
|
|
|
|
|
public override void GetStatsOut(out int numMsgs, out int numBufferedMsgs, out int numBytes, out int lastBufferedPerSecond)
|
|
|
|
|
{
|
|
|
|
|
numMsgs = 0;
|
|
|
|
|
numBufferedMsgs = 0;
|
|
|
|
|
numBytes = 0;
|
|
|
|
|
lastBufferedPerSecond = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void GetStatsIn(out int numMsgs, out int numBytes)
|
|
|
|
|
{
|
|
|
|
|
numMsgs = 0;
|
|
|
|
|
numBytes = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private QSBNetworkServer m_LocalServer;
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|