2020-12-02 12:42:26 +00:00
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
2020-12-02 21:19:10 +00:00
|
|
|
|
namespace QSB.QuantumUNET
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
|
|
|
|
public class QSBNetworkMessage
|
|
|
|
|
{
|
|
|
|
|
public static string Dump(byte[] payload, int sz)
|
|
|
|
|
{
|
|
|
|
|
var text = "[";
|
|
|
|
|
for (var i = 0; i < sz; i++)
|
|
|
|
|
{
|
|
|
|
|
text = text + payload[i] + " ";
|
|
|
|
|
}
|
|
|
|
|
return text + "]";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TMsg ReadMessage<TMsg>() where TMsg : MessageBase, new()
|
|
|
|
|
{
|
|
|
|
|
var result = Activator.CreateInstance<TMsg>();
|
|
|
|
|
result.Deserialize(reader);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReadMessage<TMsg>(TMsg msg) where TMsg : MessageBase
|
|
|
|
|
{
|
|
|
|
|
msg.Deserialize(reader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public const int MaxMessageSize = 65535;
|
|
|
|
|
|
|
|
|
|
public short msgType;
|
|
|
|
|
|
|
|
|
|
public QSBNetworkConnection conn;
|
|
|
|
|
|
|
|
|
|
public NetworkReader reader;
|
|
|
|
|
|
|
|
|
|
public int channelId;
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|