Class MessagePacker
Inheritance
System.Object
Inherited Members
Show
Syntax
public static class MessagePacker
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
Type | Description |
---|---|
System.Int32 |
GetId(Type)
Used to calculate new hash for type
Declaration
public static int GetId(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type |
Returns
Type | Description |
---|---|
System.Int32 |
Pack<T>(T, NetworkWriter)
Declaration
public static void Pack<T>(T message, NetworkWriter writer)
Parameters
Type | Name | Description |
---|---|---|
T | message | |
Mirage.Serialization.NetworkWriter | writer |
Pack<T>(T)
Declaration
public static byte[] Pack<T>(T message)
Parameters
Type | Name | Description |
---|---|---|
T | message |
Returns
Type | Description |
---|---|
System.Byte[] |
Unpack<T>(Byte[], IObjectLocator)
unpack a message we received
Declaration
public static T Unpack<T>(byte[] data, IObjectLocator objectLocator)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | |
Mirage.IObjectLocator | objectLocator | Can be null, but must be set in order to read NetworkIdentity Values |
Returns
Type | Description |
---|---|
T |
UnpackId(NetworkReader)
Declaration
public static int UnpackId(NetworkReader messageReader)
Parameters
Type | Name | Description |
---|---|---|
Mirage.Serialization.NetworkReader | messageReader |
Returns
Type | Description |
---|---|
System.Int32 |