示例#1
0
 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);
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 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);
 }
示例#6
0
        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;
        }