forked from jasonpang/RemoteDesktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.cs
More file actions
46 lines (40 loc) · 1.41 KB
/
Copy pathMessage.cs
File metadata and controls
46 lines (40 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using Lidgren.Network;
using Network.Extensions;
namespace Network
{
/// <remarks>
/// Extends Lidgren's networking library by implementing custom messages.
/// </remarks>
public abstract class Message
{
/// <summary>
/// Gets the unique identifier for this custom message type within its protocol.
/// </summary>
public ushort MessageType { get; private set; }
/// <summary>
/// Gets the protocol this message belongs to.
/// </summary>
public Protocol Protocol { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="Message"/> class.
/// </summary>
/// <param name="protocol">The protocol this message belongs to.</param>
/// <param name="messageType">Unique identifer for this custom message type.</param>
protected Message(Protocol protocol, ushort messageType)
{
if (protocol == null)
throw new ArgumentNullException("protocol");
Protocol = protocol;
MessageType = messageType;
}
public virtual void WritePayload(NetOutgoingMessage message)
{
message.Write(Protocol);
message.Write(MessageType);
}
public virtual void ReadPayload(NetIncomingMessage message)
{
}
}
}