public void CreatePayload(byte[] buffer) { Raw = buffer; var shift = 0; Header = NetworkBinary.Deserialize <string>(Raw, ref shift); Payload = Raw.Skip(shift).ToArray(); }
public static Color Deserialize(byte[] array) { var shift = 0; var r = NetworkBinary.Deserialize <float>(array, ref shift); var g = NetworkBinary.Deserialize <float>(array, ref shift); var b = NetworkBinary.Deserialize <float>(array, ref shift); var a = NetworkBinary.Deserialize <float>(array, ref shift); return(new Color(r, g, b, a)); }
public static byte[] Serialize(Color color) { var arr = new List <byte>(); arr.AddRange(NetworkBinary.Serialize(color.r)); arr.AddRange(NetworkBinary.Serialize(color.g)); arr.AddRange(NetworkBinary.Serialize(color.b)); arr.AddRange(NetworkBinary.Serialize(color.a)); return(arr.ToArray()); }
public override void Deserialize(byte[] array) { var shift = 0; var idMsg = NetworkBinary.Deserialize <ObjectSpawnMessage>(array, ref shift); Id = idMsg.Id; AssetId = idMsg.AssetId; SceneId = idMsg.SceneId; Position = idMsg.Position; Rotation = idMsg.Rotation; }
public void CreateRaw(byte[] array, string header) { Payload = array; Header = header; var headerByte = NetworkBinary.Serialize(Header); var copyPayload = Payload != null; var rawLength = copyPayload ? Payload.Length + headerByte.Length : headerByte.Length; Raw = new byte[rawLength]; headerByte.CopyTo(Raw, 0); if (copyPayload) { Payload.CopyTo(Raw, headerByte.Length); } }
public override byte[] Serialize() { return(NetworkBinary.Serialize(this)); }