Skip to main content

Class MessagePacker

Inheritance​
System.Object
Inherited Members​
Show
Syntax​
public static class MessagePacker

Fields​

ID_BYTE_SIZE​

Declaration​
public const int ID_BYTE_SIZE = 2

Properties​

MessageTypes​

Map of Message Id => Type When we receive a message, we can lookup here to find out what type it was. This is populated by the weaver.

Declaration​
public static IReadOnlyDictionary<int, Type> MessageTypes { get; }

Methods​

RegisterMessage<T>()​

Registers a message with its ID, Useful for debugging if a message handler is missing Used by weaver

Declaration​
public static void RegisterMessage<T>()

GetId<T>()​

Gets the Id from for T

Declaration​
public static int GetId<T>()
Returns​
TypeDescription
System.Int32

GetId(Type)​

Used to calculate new hash for type

Declaration​
public static int GetId(Type type)
Parameters​
TypeNameDescription
System.Typetype
Returns​
TypeDescription
System.Int32

Pack<T>(T, NetworkWriter)​

Declaration​
public static void Pack<T>(T message, NetworkWriter writer)
Parameters​
TypeNameDescription
Tmessage
Mirage.Serialization.NetworkWriterwriter

Pack<T>(T)​

Declaration​
public static byte[] Pack<T>(T message)
Parameters​
TypeNameDescription
Tmessage
Returns​
TypeDescription
System.Byte[]

Unpack<T>(Byte[], IObjectLocator)​

unpack a message we received

Declaration​
public static T Unpack<T>(byte[] data, IObjectLocator objectLocator)
Parameters​
TypeNameDescription
System.Byte[]data
Mirage.IObjectLocatorobjectLocatorCan be null, but must be set in order to read NetworkIdentity Values
Returns​
TypeDescription
T

UnpackId(NetworkReader)​

Declaration​
public static int UnpackId(NetworkReader messageReader)
Parameters​
TypeNameDescription
Mirage.Serialization.NetworkReadermessageReader
Returns​
TypeDescription
System.Int32