该功能的作用在于:把一个 byte数组打包,然后正确的解析回来
可用于网络,序列化等,支持嵌套(packet内部再放若干个packet)
用法如下
Packet pack = new Packet(1,11,2,Encoding.Default.GetBytes("haha"));
byte[] buf = pack.Pack();
Packet pac = new Packet();
pac.UnPack(buf, 0, buf.Length);
PacketReader p = new PacketReader(128);
p.Set(buf, 0, buf.Length);
p.Set(buf, 0, buf.Length);
List<Packet> ps = p.Get();
Log.L(ps.Count);
网友评论