quantum-space-buddies/QSB/QuantumUNET/QSBNetworkMessage.cs
Mister_Nebula c6c76cb395 C L E A N
2020-12-02 21:23:01 +00:00

41 lines
736 B
C#

using System;
using UnityEngine.Networking;
namespace QSB.QuantumUNET
{
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;
}
}