public List<BnetUsername> getUserFlags(BnetPacketStruct bnetPackSt, byte[] originPack) { uint totalLen = (uint)bnetPackSt.pack_data.Count + 4; BnetProtocol bnetProtocol = new BnetProtocol(); BnetPacketStruct curPackSt = new BnetPacketStruct(); List<string> bnetUserList = new List<string>(); List<BnetUsername> bnetUsernameList = new List<BnetUsername>(); for(uint i = totalLen; i < originPack.Length;) { BnetDataPack formatedData = this.readFlagHead(originPack, i); if(formatedData.data == null) { break; } else { bnetUserList.Add(Encoding.UTF8.GetString(formatedData.data)); i += formatedData.len; } } BnetPacketStruct bnetPacketSt = new BnetPacketStruct(); for (int i = 0; i < bnetUserList.Count; i++) { BnetUsername bnetUsername = bnetPacketSt.getUsername(bnetUserList[i]); bnetUsernameList.Add(bnetUsername); } return bnetUsernameList; }
public BnetPacketStruct decapsulize(byte[] data) { BnetPacketStruct bnetPacketSt = new BnetPacketStruct(); bnetPacketSt.packet_id = (BnetPacketModel) data[1]; bnetPacketSt.packet_len = (uint) ((data[2] & 0x000000FF) | (data[3] << 8 & 0x0000FF00)); for (int i=4; i<bnetPacketSt.packet_len; i++) { bnetPacketSt.pack_data.Add(data[i]); } return bnetPacketSt; }