示例#1
0
 public static byte[] Pack(byte cid, IPacket p)
 {
     lastPack = new byte[p.GetLength() + HEADERSIZE];
     Array.Copy(GenerateHeader(cid, p), lastPack, HEADERSIZE);
     Array.ConstrainedCopy(p.EncodeRaw(), 0, lastPack, HEADERSIZE, p.GetLength());
     return(lastPack);
 }
示例#2
0
 public static byte[] GenerateHeader(byte cid, IPacket p)
 {
     byte[] toret = new byte[5];
     toret[0] = (byte)((p.GetLength() + HEADERSIZE) << 8 >> 8);
     toret[1] = (byte)((p.GetLength() + HEADERSIZE) >> 8);
     toret[2] = cid;
     toret[3] = p.GetPacketType();
     toret[4] = p.GetID();
     return(toret);
 }