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
|
|
|
|
|
{
|
2020-12-03 11:56:32 +00:00
|
|
|
|
public const int MaxMessageSize = 65535;
|
|
|
|
|
public short MsgType;
|
|
|
|
|
public QSBNetworkConnection Connection;
|
|
|
|
|
public NetworkReader Reader;
|
|
|
|
|
public int ChannelId;
|
2020-12-02 12:42:26 +00:00
|
|
|
|
|
|
|
|
|
public TMsg ReadMessage<TMsg>() where TMsg : MessageBase, new()
|
|
|
|
|
{
|
|
|
|
|
var result = Activator.CreateInstance<TMsg>();
|
2020-12-03 11:56:32 +00:00
|
|
|
|
result.Deserialize(Reader);
|
2020-12-02 12:42:26 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReadMessage<TMsg>(TMsg msg) where TMsg : MessageBase
|
|
|
|
|
{
|
2020-12-03 11:56:32 +00:00
|
|
|
|
msg.Deserialize(Reader);
|
2020-12-02 12:42:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|