forked from hunterzonewu/unity-decompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkMessage.cs
More file actions
65 lines (60 loc) · 2.23 KB
/
NetworkMessage.cs
File metadata and controls
65 lines (60 loc) · 2.23 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Decompiled with JetBrains decompiler
// Type: UnityEngine.Networking.NetworkMessage
// Assembly: UnityEngine.Networking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 8B34E19C-EF53-416E-AE36-35C45BAFD2DE
// Assembly location: C:\Users\Blake\sandbox\unity\test-project\Library\UnityAssemblies\UnityEngine.Networking.dll
using System;
namespace UnityEngine.Networking
{
/// <summary>
/// <para>The details of a network message received by a client or server on a network connection.</para>
/// </summary>
public class NetworkMessage
{
/// <summary>
/// <para>The size of the largest message in bytes that can be sent on a NetworkConnection.</para>
/// </summary>
public const int MaxMessageSize = 65535;
/// <summary>
/// <para>The id of the message type of the message.</para>
/// </summary>
public short msgType;
/// <summary>
/// <para>The connection the message was recieved on.</para>
/// </summary>
public NetworkConnection conn;
/// <summary>
/// <para>A NetworkReader object that contains the contents of the message.</para>
/// </summary>
public NetworkReader reader;
/// <summary>
/// <para>The transport layer channel the message was sent on.</para>
/// </summary>
public int channelId;
/// <summary>
/// <para>Returns a string with the numeric representation of each byte in the payload.</para>
/// </summary>
/// <param name="payload">Network message payload to dump.</param>
/// <param name="sz">Length of payload in bytes.</param>
/// <returns>
/// <para>Dumped info from payload.</para>
/// </returns>
public static string Dump(byte[] payload, int sz)
{
string str = "[";
for (int index = 0; index < sz; ++index)
str = str + (object) payload[index] + " ";
return str + "]";
}
public TMsg ReadMessage<TMsg>() where TMsg : MessageBase, new()
{
TMsg instance = Activator.CreateInstance<TMsg>();
instance.Deserialize(this.reader);
return instance;
}
public void ReadMessage<TMsg>(TMsg msg) where TMsg : MessageBase
{
msg.Deserialize(this.reader);
}
}
}