Esempio n. 1
0
 /// <summary>
 /// Turn a packet into an array of bytes. If necessary zerocde it. The returned array will be the correct length.
 /// </summary>
 /// <param name="packet">The packet to encode</param>
 protected byte[] GetBytes(OpenMetaverse.Packets.Packet packet)
 {
     byte[] bytes = packet.ToBytes();
     int length = bytes.Length;
     if (packet.Header.Zerocoded) {
         byte[] zerod = new byte[8192];
         length = Helpers.ZeroEncode(bytes, bytes.Length, zerod);
         bytes = zerod.Take(length).ToArray();
     }
     return bytes;
 }