public static void Encode(List <byte> packetData, PKTReqLogin packet) { packetData.AddRange(BitConverter.GetBytes(packet.IDLength)); PacketEnDecodeUtil.StringTo(packet.ID, packetData); packetData.AddRange(BitConverter.GetBytes(packet.PWLength)); PacketEnDecodeUtil.StringTo(packet.PW, packetData); }
public static bool Decode(byte[] packetData, ref PKTReqLogin packet) { int readPos = 0; packet.IDLength = BitConverter.ToInt16(packetData, readPos); readPos += 2; PacketEnDecodeUtil.ToString(packetData, ref readPos, ref packet.ID); packet.PWLength = BitConverter.ToInt16(packetData, readPos); readPos += 2; PacketEnDecodeUtil.ToString(packetData, ref readPos, ref packet.PW); return(true); }
public void TestMethod_ReqLoginEnDecode() { PKTReqLogin loginPacket = new PKTReqLogin { IDLength = 6, ID = "test고고", PWLength = 4, PW = "1234" }; var packetData = new List<byte>(); PKTReqLoginEnDecode.Encode(packetData, loginPacket); PKTReqLogin loginPacket2 = new PKTReqLogin(); PKTReqLoginEnDecode.Decode(packetData.ToArray(), ref loginPacket2); Assert.AreEqual(loginPacket.IDLength, loginPacket2.IDLength); Assert.AreEqual(loginPacket.ID, loginPacket2.ID); Assert.AreEqual(loginPacket.PWLength, loginPacket2.PWLength); Assert.AreEqual(loginPacket.PW, loginPacket2.PW); }
public void TestMethod_ReqLoginEnDecode() { PKTReqLogin loginPacket = new PKTReqLogin { IDLength = 6, ID = "test고고", PWLength = 4, PW = "1234" }; var packetData = new List <byte>(); PKTReqLoginEnDecode.Encode(packetData, loginPacket); PKTReqLogin loginPacket2 = new PKTReqLogin(); PKTReqLoginEnDecode.Decode(packetData.ToArray(), ref loginPacket2); Assert.AreEqual(loginPacket.IDLength, loginPacket2.IDLength); Assert.AreEqual(loginPacket.ID, loginPacket2.ID); Assert.AreEqual(loginPacket.PWLength, loginPacket2.PWLength); Assert.AreEqual(loginPacket.PW, loginPacket2.PW); }
public static void Encode(List<byte> packetData, PKTReqLogin packet) { packetData.AddRange(BitConverter.GetBytes(packet.IDLength)); PacketEnDecodeUtil.StringTo(packet.ID, packetData); packetData.AddRange(BitConverter.GetBytes(packet.PWLength)); PacketEnDecodeUtil.StringTo(packet.PW, packetData); }
public static bool Decode(byte[] packetData, ref PKTReqLogin packet) { int readPos = 0; packet.IDLength = BitConverter.ToInt16(packetData, readPos); readPos += 2; PacketEnDecodeUtil.ToString(packetData, ref readPos, ref packet.ID); packet.PWLength = BitConverter.ToInt16(packetData, readPos); readPos += 2; PacketEnDecodeUtil.ToString(packetData, ref readPos, ref packet.PW); return true; }