Untitled


SUBMITTED BY: moudixblack

DATE: Aug. 5, 2017, 12:55 a.m.

UPDATED: Aug. 5, 2017, 2:09 a.m.

FORMAT: Text only

SIZE: 633 Bytes

HITS: 805

  1. public static byte[] FinalizeProtoBuf(object proto, ushort packetid)
  2. {
  3. byte[] protobuff;
  4. using (var ms = new System.IO.MemoryStream())
  5. {
  6. ProtoBuf.Serializer.Serialize(ms, proto);
  7. protobuff = ms.ToArray();
  8. byte[] buffer;
  9. buffer = new byte[12 + protobuff.Length];
  10. System.Buffer.BlockCopy(protobuff, 0, buffer, 4, protobuff.Length);
  11. Writer.Write(buffer.Length - 8, 0, buffer);
  12. Writer.Write(packetid, 2, buffer);
  13. return buffer;
  14. }
  15. }

comments powered by Disqus