2020-12-02 12:42:26 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2020-12-04 22:14:53 +00:00
|
|
|
|
namespace 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;
|
2020-12-04 09:23:27 +00:00
|
|
|
|
public QSBNetworkReader Reader;
|
2020-12-03 11:56:32 +00:00
|
|
|
|
public int ChannelId;
|
2020-12-02 12:42:26 +00:00
|
|
|
|
|
2020-12-04 09:23:27 +00:00
|
|
|
|
public TMsg ReadMessage<TMsg>() where TMsg : QSBMessageBase, new()
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-04 09:23:27 +00:00
|
|
|
|
public void ReadMessage<TMsg>(TMsg msg) where TMsg : QSBMessageBase
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
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
|
|
|
|
}
|