quantum-space-buddies/QuantumUNET/Messages/QNetworkMessage.cs

22 lines
476 B
C#
Raw Normal View History

using QuantumUNET.Transport;
2020-12-02 12:42:26 +00:00
2020-12-07 21:19:16 +00:00
namespace QuantumUNET.Messages
2020-12-02 12:42:26 +00:00
{
2020-12-23 12:58:45 +00:00
public class QNetworkMessage
2020-12-02 12:42:26 +00:00
{
2020-12-03 11:56:32 +00:00
public short MsgType;
2020-12-23 12:58:45 +00:00
public QNetworkConnection Connection;
public QNetworkReader Reader;
2020-12-03 11:56:32 +00:00
public int ChannelId;
2020-12-02 12:42:26 +00:00
2020-12-23 12:58:45 +00:00
public TMsg ReadMessage<TMsg>() where TMsg : QMessageBase, new()
2020-12-02 12:42:26 +00:00
{
var result = new TMsg();
2020-12-03 11:56:32 +00:00
result.Deserialize(Reader);
2020-12-02 12:42:26 +00:00
return result;
}
2020-12-23 12:58:45 +00:00
public void ReadMessage<TMsg>(TMsg msg) where TMsg : QMessageBase =>
2020-12-14 22:07:21 +00:00
msg.Deserialize(Reader);
2020-12-02 12:42:26 +00:00
}
2020-12-03 08:28:05 +00:00
}