Skip to main content
Version: 2.x

Class MsgPackWriter

Rudimentary Msgpack implementation that will be used for sending RPC to the server.

Assembly: cs.temp.dll.dll
Declaration
public class MsgPackWriter : IMsgPackWriter, IDisposable

Implements:
OdinNative.Utils.MessagePack.IMsgPackWriter, Odin.IDisposable

Properties

Encoding

Used Encoding defaults to UTF8

Declaration
public Encoding Encoding { get; }

LittleEndianness

Indicates the value byte order

Declaration
public bool LittleEndianness { get; protected set; }

Methods

Clear()

Clear stream buffer

Declaration
public void Clear()

Create(byte[])

Create writer with a prefilled stream buffer

Declaration
public static MsgPackWriter Create(byte[] bytes)
Returns

OdinNative.Utils.MessagePack.MsgPackWriter: writer

Parameters
TypeNameDescription
System.Byte[]bytesdata that will be pushed into the stream

Create(byte[], Encoding)

Declaration
public static MsgPackWriter Create(byte[] bytes, Encoding encoding)
Returns

OdinNative.Utils.MessagePack.MsgPackWriter

Parameters
TypeName
System.Byte[]bytes
Odin.Encodingencoding

Write(uint)

Set MsgPackToken based on the unsigend value size

Declaration
public int Write(uint value)
Returns

System.Int32: size written

Parameters
TypeNameDescription
System.UInt32valuevalue to write and identify size

Write(int)

Set MsgPackToken based on the sigend value size

Declaration
public int Write(int value)
Returns

System.Int32: size written

Parameters
TypeNameDescription
System.Int32valuevalue to write and identify size

WriteByte(byte)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Uint8

Declaration
public void WriteByte(byte value)
Parameters
TypeName
System.Bytevalue

WriteSByte(sbyte)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Int8

Declaration
public void WriteSByte(sbyte value)
Parameters
TypeName
System.SBytevalue

WriteShortValue(short, bool)

Declaration
protected void WriteShortValue(short value, bool isLittleEndian)
Parameters
TypeName
System.Int16value
System.BooleanisLittleEndian

WriteUShortValue(ushort, bool)

Declaration
protected void WriteUShortValue(ushort value, bool isLittleEndian)
Parameters
TypeName
System.UInt16value
System.BooleanisLittleEndian

WriteFloatValue(float, bool)

Declaration
protected void WriteFloatValue(float value, bool isLittleEndian)
Parameters
TypeName
System.Singlevalue
System.BooleanisLittleEndian

WriteDoubleValue(double, bool)

Declaration
protected void WriteDoubleValue(double value, bool isLittleEndian)
Parameters
TypeName
System.Doublevalue
System.BooleanisLittleEndian

WriteIntValue(int, bool)

Declaration
protected void WriteIntValue(int value, bool isLittleEndian)
Parameters
TypeName
System.Int32value
System.BooleanisLittleEndian

WriteUIntValue(uint, bool)

Declaration
protected void WriteUIntValue(uint value, bool isLittleEndian)
Parameters
TypeName
System.UInt32value
System.BooleanisLittleEndian

WriteLongValue(long, bool)

Declaration
protected void WriteLongValue(long value, bool isLittleEndian)
Parameters
TypeName
System.Int64value
System.BooleanisLittleEndian

WriteULongValue(ulong, bool)

Declaration
protected void WriteULongValue(ulong value, bool isLittleEndian)
Parameters
TypeName
System.UInt64value
System.BooleanisLittleEndian

WriteShort(short)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Int16

Declaration
public void WriteShort(short value)
Parameters
TypeName
System.Int16value

WriteUShort(ushort)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Uint16

Declaration
public void WriteUShort(ushort value)
Parameters
TypeName
System.UInt16value

WriteInt(int)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Int32

Declaration
public void WriteInt(int value)
Parameters
TypeName
System.Int32value

WriteUInt(uint)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Uint32

Declaration
public void WriteUInt(uint value)
Parameters
TypeName
System.UInt32value

WriteLong(long)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Int64

Declaration
public void WriteLong(long value)
Parameters
TypeName
System.Int64value

WriteULong(ulong)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Uint64

Declaration
public void WriteULong(ulong value)
Parameters
TypeName
System.UInt64value

WriteFloat(float)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Float32

Declaration
public void WriteFloat(float value)
Parameters
TypeName
System.Singlevalue

WriteDouble(double)

Write value with token OdinNative.Utils.MessagePack.MsgPackToken.Float64

Declaration
public void WriteDouble(double value)
Parameters
TypeName
System.Doublevalue

WriteBool(bool)

Write fixedbool of either OdinNative.Utils.MessagePack.MsgPackToken.True or OdinNative.Utils.MessagePack.MsgPackToken.False

Declaration
public void WriteBool(bool value)
Parameters
TypeName
System.Booleanvalue

WriteString(string)

Write string with writer encoding (default UTF8)

Declaration
public int WriteString(string value)
Returns

System.Int32: size written

Parameters
TypeName
System.Stringvalue

WriteString(string, Encoding)

MessagePack header is big-endian, value binarywriter default little-endian

Declaration
public int WriteString(string value, Encoding encoding)
Returns

System.Int32

Parameters
TypeName
System.Stringvalue
Odin.Encodingencoding

WriteBinary(byte[])

MessagePack header is big-endian, value binarywriter default little-endian

Declaration
public int WriteBinary(byte[] value)
Returns

System.Int32

Parameters
TypeName
System.Byte[]value

WriteArrayHeader(uint)

MessagePack header is big-endian, value binarywriter default little-endian

Declaration
public int WriteArrayHeader(uint count)
Returns

System.Int32

Parameters
TypeName
System.UInt32count

WriteMapHeader(uint)

MessagePack header is big-endian value binarywriter default little-endian

Declaration
public int WriteMapHeader(uint count)
Returns

System.Int32

Parameters
TypeName
System.UInt32count

GetBytes()

Get raw bytes from the stream buffer

Declaration
public byte[] GetBytes()
Returns

System.Byte[]: Msgpack bytes### GetLength() Get raw bytes from the stream buffer

Declaration
public long GetLength()
Returns

System.Int64: Msgpack buffer length### GetBuffer(out ArraySegment<byte>) Get raw bytes from the underlying stream buffer

Declaration
public bool GetBuffer(out ArraySegment<byte> buffer)
Returns

System.Boolean: true on success or false

Parameters
TypeNameDescription
Odin.ArraySegment<System.Byte>bufferunderlying stream buffer

Append(byte[])

Append bytes to the stream at the currrent stream position

Declaration
public void Append(byte[] bytes)
Parameters
TypeNameDescription
System.Byte[]bytesbytes to write

ToString()

String representation of the stream based on encoding (default UTF8)

Declaration
public override string ToString()
Returns

System.String: string of stream### ToHex() String representation of the stream in hex

Declaration
public string ToHex()
Returns

System.String: hex string of stream### Dispose(bool)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeName
System.Booleandisposing

Dispose()

dispose

Declaration
public void Dispose()

WriteByte(ref List<byte>, byte)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Uint8 token to bytes

Declaration
public static void WriteByte(ref List<byte> bytes, byte value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.Bytevalue

WriteSByte(ref List<byte>, sbyte)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Int8 token to bytes

Declaration
public static void WriteSByte(ref List<byte> bytes, sbyte value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.SBytevalue

WriteShort(ref List<byte>, short)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Int16 token to bytes

Declaration
public static void WriteShort(ref List<byte> bytes, short value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.Int16value

WriteUShort(ref List<byte>, ushort)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Uint16 token to bytes

Declaration
public static void WriteUShort(ref List<byte> bytes, ushort value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.UInt16value

WriteInt(ref List<byte>, int)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Int32 token to bytes

Declaration
public static void WriteInt(ref List<byte> bytes, int value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.Int32value

WriteUInt(ref List<byte>, uint)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Uint32 token to bytes

Declaration
public static void WriteUInt(ref List<byte> bytes, uint value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.UInt32value

WriteLong(ref List<byte>, long)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Int64 token to bytes

Declaration
public static void WriteLong(ref List<byte> bytes, long value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.Int64value

WriteULong(ref List<byte>, ulong)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Uint64 token to bytes

Declaration
public static void WriteULong(ref List<byte> bytes, ulong value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.UInt64value

WriteFloat(ref List<byte>, float)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Float32 token to bytes

Declaration
public static void WriteFloat(ref List<byte> bytes, float value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.Singlevalue

WriteDouble(ref List<byte>, double)

Append value with OdinNative.Utils.MessagePack.MsgPackToken.Float64 token to bytes

Declaration
public static void WriteDouble(ref List<byte> bytes, double value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.Doublevalue

WriteBool(ref List<byte>, bool)

Append fixedbool with either OdinNative.Utils.MessagePack.MsgPackToken.True or OdinNative.Utils.MessagePack.MsgPackToken.False to bytes

Declaration
public static void WriteBool(ref List<byte> bytes, bool value)
Parameters
TypeName
Odin.List<System.Byte>bytes
System.Booleanvalue

WriteString(ref List<byte>, string, Encoding)

Append string value with size based token to bytes

Declaration
public static int WriteString(ref List<byte> bytes, string value, Encoding encoding)
Returns

System.Int32: size written

Parameters
TypeName
Odin.List<System.Byte>bytes
System.Stringvalue
Odin.Encodingencoding

WriteBinary(ref List<byte>, byte[])

Append values with size based token to bytes

Declaration
public static int WriteBinary(ref List<byte> bytes, byte[] value)
Returns

System.Int32

Parameters
TypeName
Odin.List<System.Byte>bytes
System.Byte[]value

Implements