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

22 lines
533 B
C#
Raw Normal View History

2020-12-02 12:42:26 +00:00
using System;
2020-12-07 21:19:16 +00:00
namespace QuantumUNET.Messages
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-14 21:58:00 +00:00
public void ReadMessage<TMsg>(TMsg msg) where TMsg : QSBMessageBase => msg.Deserialize(Reader);
2020-12-02 12:42:26 +00:00
}
2020-12-03 08:28:05 +00:00
}