Example #1
0
        protected override void ProcessFirstMessage(bool isChecksummed)
        {
            if (!isChecksummed)
            {
                ProcessStatusMessage();
                return;
            }

            InMessage.GetByte();             //Protocol Id
            InMessage.GetUInt16();           //Client OS
            Version = InMessage.GetUInt16(); //Client Version

            if (Version < Constants.ClientVersionMin || Version > Constants.ClientVersionMax)
            {
                Disconnect("Only clients with protocol " + Constants.ClientVersionStr + " allowed!", Version);
                return;
            }

            //This is 10.76 server, only handling 10.76 client bytes
            InMessage.SkipBytes(17);

            /*
             * Skipped bytes:
             * 4 bytes: protocolVersion
             * 12 bytes: dat, spr, pic signatures (4 bytes each)
             * 1 byte: 0
             *
             */

            if (!InMessage.RsaDecrypt())
            {
                Logger.Log(LogLevels.Information, "LoginConnection: Message could not be decrypted");
                Disconnect();
                return;
            }

            XteaKey[0]          = InMessage.GetUInt32();
            XteaKey[1]          = InMessage.GetUInt32();
            XteaKey[2]          = InMessage.GetUInt32();
            XteaKey[3]          = InMessage.GetUInt32();
            IsEncryptionEnabled = true;

            string accountName = InMessage.GetString();

            byte[] password = InMessage.GetBytes(InMessage.GetUInt16());

            DispatcherManager.DatabaseDispatcher.AddTask(() => HandleLoginPacket(accountName, password));
        }