public byte[] GetResponse(params BaseRequestObject[] requestObjects) { var revBytes = new List <byte[]> { ReversedBytes.WriteUshort(47806), //magic number ReversedBytes.WriteByte(123), //???? ReversedBytes.WriteByte(213), //random separator ReversedBytes.WriteInt(876), //size of response, doesn't really matter ReversedBytes.WriteUshort((ushort)requestObjects.Length), requestObjects.SelectMany(x => x.GetBytes()).ToArray() }; return(revBytes.SelectMany(x => x).ToArray()); }
public override byte[] GetBytes() { var revBytes = new List <byte[]> { ReversedBytes.WriteByte(WhereToStore), ReversedBytes.WriteByte(ObjectType), }; List <byte> content = new List <byte>(); foreach (var item in Content) { if (item is int) { content.AddRange(ReversedBytes.WriteInt((int)item).ToList()); } else if (item is string) { content.AddRange(ReversedBytes.WriteString((string)item).ToList()); } else if (item is byte) { content.AddRange(ReversedBytes.WriteByte((byte)item).ToList()); } else if (item is ushort) { content.AddRange(ReversedBytes.WriteUshort((ushort)item).ToList()); } else { throw new NotImplementedException(); } } revBytes.Add(ReversedBytes.WriteUshort((ushort)content.Count)); revBytes.Add(content.ToArray()); return(revBytes.SelectMany(x => x).ToArray()); }