コード例 #1
0
        public bool StartRequest(int retry)
        {
            byte[] packet = new byte[]
            {
                (byte)Code.StartRequest, (byte)(0x02 + retry),
                PacketUtils.RandomByte(), PacketUtils.RandomByte(),
                0x6a, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00
            };
            Constants.logger.log("Preparing for StartRequest Packet:\n" + BitConverter.ToString(packet));
            byte[] receive = NetworkUtils.SendUDPDatagram(packet);

            if (receive[0] == (byte)Code.StartResponse)
            {
                Constants.logger.log("Received success StartRequest response:\n" + BitConverter.ToString(receive));
                Array.Copy(receive, 4, challenge, 0, 4);
                MD5A = PacketUtils.MD5A((byte)Code.LoginAuth, 0x01, challenge, password);
                MD5B = PacketUtils.MD5B(challenge, password);
                Array.Copy(receive, 20, IP, 0, 4);
                Constants.logger.log("Successfully get IP:\n" + BitConverter.ToString(IP));
                return(true);
            }
            Constants.logger.error("Received failure StartRequest response:\n" + BitConverter.ToString(receive));
            return(false);
        }