2020-12-07 21:19:16 +00:00
|
|
|
|
using QuantumUNET.Messages;
|
2020-12-16 09:08:38 +00:00
|
|
|
|
using QuantumUNET.Transport;
|
2020-12-07 21:19:16 +00:00
|
|
|
|
|
|
|
|
|
namespace QuantumUNET
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
2020-12-23 12:58:45 +00:00
|
|
|
|
internal class QULocalConnectionToClient : QNetworkConnection
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public QULocalConnectionToClient(QLocalClient localClient)
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
|
|
|
|
address = "localClient";
|
2020-12-08 09:03:10 +00:00
|
|
|
|
LocalClient = localClient;
|
2020-12-02 18:40:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public QLocalClient LocalClient { get; }
|
2020-12-02 18:40:38 +00:00
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override bool Send(short msgType, QMessageBase msg)
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
2020-12-08 09:03:10 +00:00
|
|
|
|
LocalClient.InvokeHandlerOnClient(msgType, msg, 0);
|
2020-12-02 18:40:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override bool SendUnreliable(short msgType, QMessageBase msg)
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
2020-12-08 09:03:10 +00:00
|
|
|
|
LocalClient.InvokeHandlerOnClient(msgType, msg, 1);
|
2020-12-02 18:40:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override bool SendByChannel(short msgType, QMessageBase msg, int channelId)
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
2020-12-08 09:03:10 +00:00
|
|
|
|
LocalClient.InvokeHandlerOnClient(msgType, msg, channelId);
|
2020-12-02 18:40:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool SendBytes(byte[] bytes, int numBytes, int channelId)
|
|
|
|
|
{
|
2020-12-08 09:03:10 +00:00
|
|
|
|
LocalClient.InvokeBytesOnClient(bytes, channelId);
|
2020-12-02 18:40:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override bool SendWriter(QNetworkWriter writer, int channelId)
|
2020-12-02 18:40:38 +00:00
|
|
|
|
{
|
2020-12-08 09:03:10 +00:00
|
|
|
|
LocalClient.InvokeBytesOnClient(writer.AsArray(), channelId);
|
2020-12-02 18:40:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|