public override void OnHttpStatusOK(QQHttpResponse response)
        {
            //{"retcode":0,"result":{"uin":236557647,"cip":1991953329,"index":1075,"port":51494,"status":"online","vfwebqq":"41778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133332e342e31373200005b9200000549016e04004f95190e6d0000000a4052347371696a62724f6d0000002841778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","user_state":0,"f":0}}

            string    str     = response.GetResponseString();
            JObject   json    = JObject.Parse(str);
            QQSession session = Context.Session;
            QQAccount account = Context.Account;

            if (json["retcode"].ToString() == "0")
            {
                JObject ret = json["result"].ToObject <JObject>();
                account.Uin       = ret["uin"].ToObject <long>();
                account.QQ        = ret["uin"].ToObject <long>();
                session.SessionId = ret["psessionid"].ToString();
                session.Vfwebqq   = ret["vfwebqq"].ToString();
                account.Status    = QQStatus.ValueOfRaw(ret["status"].ToString());
                session.State     = QQSessionState.ONLINE;
                session.Index     = ret["index"].ToObject <int>();
                session.Port      = ret["port"].ToObject <int>();
                NotifyActionEvent(QQActionEventType.EVT_OK, null);
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.INVALID_RESPONSE));  //TODO ..
            }
        }
Beispiel #2
0
        private void doCheckVerify(AbstractActionFuture future)
        {
            LoginModule login   = (LoginModule)getContext().getModule(AbstractModule.Type.LOGIN);
            QQAccount   account = (QQAccount)getContext().getAccount();

            login.checkVerify(account.getUsername(), delegate(QQActionEvent evt) {
                if (evt.getType() == QQActionEvent.Type.EVT_OK)
                {
                    CheckVerifyArgs args =
                        (CheckVerifyArgs)(evt.getTarget());
                    account.setUin(args.uin);
                    if (args.result == 0)
                    {
                        doWebLogin(args.code, future);
                    }
                    else
                    {
                        doGetVerify("为了保证您账号的安全,请输入验证码中字符继续登录。", future);
                    }
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_ERROR)
                {
                    future.notifyActionEvent(
                        QQActionEvent.Type.EVT_ERROR,
                        evt.getTarget());
                }
            });
        }
Beispiel #3
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type   = buf.BeReadUInt16();   //type
            var length = buf.BeReadUInt16();   //length

            this.WSubVer = buf.BeReadUInt16(); //wSubVer
            if (this.WSubVer == 0x0001)
            {
                var len    = buf.BeReadUInt16();
                var buffer = buf.ReadBytes(len);
                var bufAccountBasicInfo = new BinaryReader(new MemoryStream(buffer));

                len    = bufAccountBasicInfo.BeReadUInt16();
                buffer = bufAccountBasicInfo.ReadBytes(len);
                var info = new BinaryReader(new MemoryStream(buffer));
                var wSsoAccountWFaceIndex = info.BeReadUInt16();
                len = info.ReadByte();
                if (len > 0)
                {
                    user.NickName = Encoding.UTF8.GetString(info.ReadBytes(len));
                }

                user.Gender = info.ReadByte();
                var dwSsoAccountDwUinFlag = info.BeReadUInt32();
                user.Age = info.ReadByte();

                var bufStOther =
                    bufAccountBasicInfo.ReadBytes(
                        (Int32)(bufAccountBasicInfo.BaseStream.Length - bufAccountBasicInfo.BaseStream.Position));
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }
        }
Beispiel #4
0
        private void doGetVerify(String reason, AbstractActionFuture future)
        {
            QQAccount   account = (QQAccount)(getContext().getAccount());
            LoginModule login   = (LoginModule)getContext().getModule(AbstractModule.Type.LOGIN);

            login.getCaptcha(account.getUin(), delegate(QQActionEvent evt) {
                if (evt.getType() == QQActionEvent.Type.EVT_OK)
                {
                    QQNotifyEventArgs.ImageVerify verify = new QQNotifyEventArgs.ImageVerify();

                    verify.type   = QQNotifyEventArgs.ImageVerify.VerifyType.LOGIN;
                    verify.image  = (BitmapImage)evt.getTarget();
                    verify.reason = reason;
                    verify.future = future;

                    getContext().fireNotify(new QQNotifyEvent(QQNotifyEvent.Type.CAPACHA_VERIFY, verify));
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_ERROR)
                {
                    future.notifyActionEvent(
                        QQActionEvent.Type.EVT_ERROR,
                        (QQException)evt.getTarget());
                }
            });
        }
Beispiel #5
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type   = buf.BeReadUInt16(); //type
            var length = buf.BeReadUInt16(); //length

            buf.ReadBytes(length);
        }
Beispiel #6
0
        private void doWebLogin(String verifyCode, AbstractActionFuture future)
        {
            LoginModule login   = (LoginModule)getContext().getModule(AbstractModule.Type.LOGIN);
            QQAccount   account = (QQAccount)getContext().getAccount();

            login.webLogin(account.getUsername(), account.getPassword(),
                           account.getUin(), verifyCode, delegate(QQActionEvent evt) {
                if (evt.getType() == QQActionEvent.Type.EVT_OK)
                {
                    doCheckLoginSig((String)evt.getTarget(), future);
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_ERROR)
                {
                    QQException ex = (QQException)(evt.getTarget());
                    if (ex.getError() == QQWpfApplication1.action.QQException.QQErrorCode.WRONG_CAPTCHA)
                    {
                        doGetVerify(ex.Message, future);
                    }
                    else
                    {
                        future.notifyActionEvent(
                            QQActionEvent.Type.EVT_ERROR,
                            (QQException)evt.getTarget());
                    }
                }
            });
        }
Beispiel #7
0
        /// <summary>
        /// 构造方法,初始化模块和服务
        /// </summary>
        ///// <param name="username">账号(二维码登录留空)</param>
        ///// <param name="password">密码(二维码登录留空)</param>
        /// <param name="notifyListener">监听器</param>
        /// <param name="actorDispatcher">线程执行器</param>
        /// <param name="logger">日志记录器</param>
        public WebQQClient(QQNotifyListener notifyListener    = null,
                           IQQActorDispatcher actorDispatcher = null, IQQLogger logger = null)
        {
            _modules  = new Dictionary <QQModuleType, IQQModule>();
            _services = new Dictionary <QQServiceType, IQQService>();

            _modules.Add(QQModuleType.LOGIN, new LoginModule());
            _modules.Add(QQModuleType.PROC, new ProcModule());
            _modules.Add(QQModuleType.USER, new UserModule());
            _modules.Add(QQModuleType.BUDDY, new BuddyModule());
            _modules.Add(QQModuleType.CATEGORY, new CategoryModule());
            _modules.Add(QQModuleType.GROUP, new GroupModule());
            _modules.Add(QQModuleType.CHAT, new ChatModule());
            _modules.Add(QQModuleType.DISCUZ, new DiscuzModule());
            _modules.Add(QQModuleType.EMAIL, new EmailModule());
            _services.Add(QQServiceType.HTTP, new HttpService());

            Account = new QQAccount
            {
                Username = string.Empty,
                Password = string.Empty
            };
            Session          = new QQSession();
            Store            = new QQStore();
            NotifyListener   = notifyListener;
            _actorDispatcher = actorDispatcher ?? new SimpleActorDispatcher();
            Logger           = logger ?? new EmptyQQLogger();
            Logger.Context   = this;
            Init();
        }
Beispiel #8
0
        /// <summary>
        /// 构造方法,初始化模块和服务
        /// </summary>
        /// <param name="username">账号</param>
        /// <param name="password">密码</param>
        /// <param name="notifyListener">监听器</param>
        /// <param name="actorDispatcher">线程执行器</param>
        public WebQQClient(string username, string password,
                           QQNotifyHandler notifyListener, IQQActorDispatcher actorDispatcher)
        {
            _modules  = new Dictionary <QQModuleType, IQQModule>();
            _services = new Dictionary <QQServiceType, IQQService>();

            _modules.Add(QQModuleType.LOGIN, new LoginModule());
            _modules.Add(QQModuleType.PROC, new ProcModule());
            _modules.Add(QQModuleType.USER, new UserModule());
            _modules.Add(QQModuleType.BUDDY, new BuddyModule());
            _modules.Add(QQModuleType.CATEGORY, new CategoryModule());
            _modules.Add(QQModuleType.GROUP, new GroupModule());
            _modules.Add(QQModuleType.CHAT, new ChatModule());
            _modules.Add(QQModuleType.DISCUZ, new DiscuzModule());
            _modules.Add(QQModuleType.EMAIL, new EmailModule());
            _services.Add(QQServiceType.HTTP, new HttpService());

            Account = new QQAccount
            {
                Username = username,
                Password = password
            };
            Session          = new QQSession();
            Store            = new QQStore();
            NotifyListener   = notifyListener;
            _actorDispatcher = actorDispatcher;

            Init();
        }
Beispiel #9
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type    = buf.BeReadUInt16(); //type
            var length  = buf.BeReadUInt16(); //length
            var Data    = buf.ReadBytes(length);
            var bufData = new BinaryReader(new MemoryStream(Data));

            this.WSubVer = bufData.BeReadUInt16(); //wSubVer
            if (this.WSubVer == 0x0001)
            {
                var buffer = bufData.ReadBytes(16);
                user.TXProtocol.BufSessionKey = buffer;

                var len = bufData.BeReadUInt16();
                buffer = bufData.ReadBytes(len);
                user.TXProtocol.BufSigSession = buffer;

                len    = bufData.BeReadUInt16();
                buffer = bufData.ReadBytes(len);
                user.TXProtocol.BufPwdForConn = buffer;
                if (bufData.BaseStream.Length > bufData.BaseStream.Position)
                {
                    len = bufData.BeReadUInt16(); //bufBill
                    if (len > 0)
                    {
                        bufData.ReadBytes(len);
                    }
                }
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }
        }
Beispiel #10
0
        /** {@inheritDoc} */
        public override void onHttpStatusOK(QQHttpResponse response)
        {
            //{"retcode":0,"result":{"uin":236557647,"cip":1991953329,"index":1075,"port":51494,"status":"online","vfwebqq":"41778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133332e342e31373200005b9200000549016e04004f95190e6d0000000a4052347371696a62724f6d0000002841778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","user_state":0,"f":0}}
            JSONObject json    = new JSONObject(new JSONTokener(new StringReader(response.getResponseMessage())));
            QQSession  session = getContext().getSession();
            QQAccount  account = (QQAccount)getContext().getAccount();

            if (json.getInt("retcode") == 0)
            {
                JSONObject ret = json.getJSONObject("result");
                account.setUin(ret.getLong("uin"));
                account.setQQ(ret.getLong("uin"));
                session.setSessionId(ret.getString("psessionid"));
                session.setVfwebqq(ret.getString("vfwebqq"));
                account.setStatus(QQStatus.ONLINE);
                session.setState(QQSession.State.ONLINE);
                session.setIndex(ret.getInt("index"));
                session.setPort(ret.getInt("port"));
                notifyActionEvent(QQActionEvent.Type.EVT_OK, null);
            }
            else
            {
                notifyActionEvent(QQActionEvent.Type.EVT_ERROR, new QQException(QQWpfApplication1.action.QQException.QQErrorCode.INVALID_RESPONSE));            //TODO ..
            }
        }
Beispiel #11
0
        public Byte[] Get_Tlv(QQAccount user)
        {
            var data = new BinaryWriter(new MemoryStream());

            if (this.WSubVer == 0x0002)
            {
                data.BeWrite(this.WSubVer); //wSubVer
                var newbyte = user.TXProtocol.BufTgt;
                var flag    = this.EncodeLoginFlag(newbyte, ClientDefines.QqexeMD5);
                data.Write(user.MD51);
                data.Write(flag);
                data.Write((Byte)0x10);
                data.BeWrite(0);
                data.BeWrite(2);
                var qddata = QdData.GetQdData(user);
                data.WriteKey(qddata);
                data.BeWrite(0);
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }

            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #12
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type   = buf.BeReadUInt16(); //type
            var length = buf.BeReadUInt16(); //length

            user.TXProtocol.DwServerIP = ByteHelper.GetIpStringFromBytes(buf.ReadBytes(4));
        }
Beispiel #13
0
 public ServerTouchPacket(QQAccount user, Boolean redirect) : base(user)
 {
     this.Sequence  = GetNextSeq();
     this.Redirect  = redirect;
     this.SecretKey = !redirect ? this.Account.QQPacket0825Key : this.Account.QQPacketRedirectionkey;
     this.Command   = PacketCommands.Login0X0825;
 }
Beispiel #14
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type   = buf.BeReadUInt16();   //type
            var length = buf.BeReadUInt16();   //length

            this.WSubVer = buf.BeReadUInt16(); //wSubVer
            if (this.WSubVer == 0x0001)
            {
                user.TXProtocol.SessionKey = buf.ReadBytes(16);
                var dwUin      = buf.BeReadInt32();
                var dwClientIP = ByteHelper.GetIpStringFromBytes(buf.ReadBytes(4)); //IP地址
                user.TXProtocol.WClientPort = buf.BeReadUInt16();
                DateTime dwServerTime      = ByteHelper.GetDateTimeFromMillis(buf.BeReadInt32());
                var      unknow            = buf.BeReadInt32();
                var      cPassSeqId        = buf.ReadByte();
                var      dwReLoginConnIP   = buf.ReadBytes(4);
                var      dwReLoginCtrlFlag = buf.BeReadInt32();

                Int32 len = buf.BeReadUInt16();
                var   bufComputerIdSig = buf.ReadBytes(len);

                len = buf.ReadByte();
                var unknow2 = buf.ReadBytes(len);

                len = buf.BeReadUInt16();
                var unknow3 = buf.ReadBytes(len);
                var a       = new BinaryReader(new MemoryStream(unknow3));
                a.ReadByte();
                var dwConnIP2 = a.ReadBytes(4);
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }
        }
Beispiel #15
0
        public Byte[] Get_Tlv(QQAccount user)
        {
            var data = new BinaryWriter(new MemoryStream());

            if (this.WSubVer == 0x0001)
            {
                data.BeWrite(this.WSubVer); //wSubVer
                data.Write(user.TXProtocol.XxooB);
                data.Write((Byte)2);
                data.BeUshortWrite(0x0014);
                data.BeWrite(0x01010010);
                data.Write(ByteHelper.RandomKey());
                data.BeUshortWrite(0x0014);
                data.BeWrite(0x01020010);
                data.Write(ByteHelper.RandomKey());
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }

            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #16
0
        public Byte[] Get_Tlv(QQAccount user)
        {
            if (user.QQ != 0)
            {
                return(null);
            }

            var data = new BinaryWriter(new MemoryStream());

            if (this.WSubVer == 0x0000)
            {
                data.BeWrite(this.WSubVer);              //wSubVer
                var bufAccount = ByteHelper.HexStringToByteArray(ByteHelper.NumToHexString(user.QQ));
                data.BeWrite((UInt16)bufAccount.Length); //账号长度
                data.Write(bufAccount);                  //账号
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }

            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #17
0
        public Byte[] Get_Tlv(QQAccount user)
        {
            var data = new BinaryWriter(new MemoryStream());

            if (this.WSubVer == 0x0001)
            {
                data.BeWrite(this.WSubVer);
                //OfficialKey
                data.Write(new Byte[]
                           { 0x9e, 0x9b, 0x03, 0x23, 0x6d, 0x7f, 0xa8, 0x81, 0xa8, 0x10, 0x72, 0xec, 0x50, 0x97, 0x96, 0x8e });
                var bufSigPic = user.TXProtocol.BufSigPic ?? ByteHelper.RandomKey(56);
                data.WriteKey(bufSigPic);
                //Official
                data.WriteKey(new Byte[]
                {
                    0x60, 0x6f, 0x27, 0xd7, 0xdc, 0x40, 0x46, 0x33, 0xa6, 0xc4, 0xb9, 0x05, 0x7e, 0x60, 0xfb, 0x64,
                    0x1e, 0x75, 0x65, 0x6
                });
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }

            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #18
0
        public Byte[] Get_Tlv(QQAccount user)
        {
            var data = new BinaryWriter(new MemoryStream());

            if (this.WSubVer == 0x0001)
            {
                data.BeWrite(this.WSubVer);                                             //wSubVer
                data.Write(ByteHelper.IPStringToByteArray(user.TXProtocol.DwServerIP)); //LastServerIP - 服务器最后的登录IP,可以为0
                data.Write((Byte)user.TXProtocol.RedirectIP.Count);                     //cRedirectCount - 重定向的次数(IP的数量)
                foreach (var ip in user.TXProtocol.RedirectIP)
                {
                    data.Write(ip);
                }

                data.Write(user.TXProtocol.CPingType); //cPingType
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }

            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #19
0
        public Byte[] Get_Tlv(QQAccount user)
        {
            var      Buf       = new BinaryWriter(new MemoryStream());
            DateTime _dataTime = DateTime.Now;

            Buf.BeWrite(0);
            Buf.BeWrite(user.QQ);
            Buf.Write(new Byte[] { 0x76, 0x71, 0x01, 0x9d });
            Buf.BeWrite(ByteHelper.GetTimeMillis(_dataTime));
            Buf.BeWrite(user.TXProtocol.DwServiceId);
            Buf.Write(new Byte[] { 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x00, 0x04, 0x5f, 0x80, 0x33, 0x01, 0x01 });
            Buf.BeWrite(user.TXProtocol.DwClientVer);
            Buf.Write(new Byte[]
                      { 0x66, 0x35, 0x4d, 0xf1, 0xab, 0xdc, 0x98, 0xf0, 0x70, 0x69, 0xfc, 0x2a, 0x2b, 0x86, 0x06, 0x1b });
            Buf.BeWrite(user.TXProtocol.SubVer);

            var Data = new BinaryWriter(new MemoryStream());

            Data.BeWrite(0);
            Data.BeWrite(user.QQ);
            Data.Write(new Byte[] { 0x76, 0x71, 0x01, 0x9d });
            Data.BeWrite(ByteHelper.GetTimeMillis(_dataTime));
            Data.Write(user.TXProtocol.DwPubNo);

            Buf.Write((Byte)Data.BaseStream.Length * 3);
            Buf.Write(Data.ToByteArray());
            Buf.Write(Data.ToByteArray());
            Buf.Write(Data.ToByteArray());


            this.FillHead(this.Command);
            this.FillBody(Buf.ToByteArray(), Buf.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #20
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type   = buf.BeReadUInt16(); //type
            var length = buf.BeReadUInt16(); //length

            user.TXProtocol.BufTgtgtKey = buf.ReadBytes(length);
        }
Beispiel #21
0
        /// <summary>
        ///     LoginReason
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public Byte[] Get_Tlv(QQAccount user)
        {
            var data = new BinaryWriter(new MemoryStream());

            if (this.WSubVer == 0x0002)
            {
                data.BeWrite(this.WSubVer); //wSubVer
                data.BeUshortWrite(1);
                data.BeUshortWrite(0);
                data.BeUshortWrite(1);
                data.BeUshortWrite(0);
                data.BeUshortWrite(0);
                data.BeUshortWrite(0);
                data.BeUshortWrite(0);
                data.BeUshortWrite(0);
            }
            else if (this.WSubVer == 0x0001)
            {
                data.BeWrite(this.WSubVer); //wSubVer
                data.BeUshortWrite(1);
                data.BeUshortWrite(0);
                data.BeUshortWrite(0);
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }

            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #22
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type   = buf.BeReadUInt16(); //type
            var length = buf.BeReadUInt16(); //length

            this.Parser_Tlv2(user, buf, length);
        }
Beispiel #23
0
        public void Parser_Tlv(QQAccount user, BinaryReader buf)
        {
            var type   = buf.BeReadUInt16();   //type
            var length = buf.BeReadUInt16();   //length

            this.WSubVer = buf.BeReadUInt16(); //wSubVer
            if (this.WSubVer == 0x0001)
            {
                Int32 len          = buf.BeReadUInt16();
                var   buffer       = buf.ReadBytes(len);
                var   sig          = new BinaryReader(new MemoryStream(buffer));
                var   dwUinLevel   = sig.BeReadInt32();
                var   dwUinLevelEx = sig.BeReadInt32();

                len    = sig.BeReadUInt16();
                buffer = sig.ReadBytes(len);
                var buf24ByteSignature = buffer;

                len    = sig.BeReadUInt16();
                buffer = sig.ReadBytes(len);
                var buf32ByteValueAddedSignature = buffer;

                len    = sig.BeReadUInt16();
                buffer = sig.ReadBytes(len);
                var buf12ByteUserBitmap = buffer;

                user.TXProtocol.ClientKey = buf32ByteValueAddedSignature;
                //client.QQUser.ClientKeyString = Util.ToHex(buf32byteValueAddedSignature).Replace(" ", "");
                //client.GetCookie();
            }
            else
            {
                throw new Exception($"{this.Name} 无法识别的版本号 {this.WSubVer}");
            }
        }
Beispiel #24
0
        public System.Byte[] Get_Tlv(QQAccount user)
        {
            var qddata = QdData.GetQdData(user);

            this.FillHead(this.Command);
            this.FillBody(qddata, qddata.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #25
0
        public System.Byte[] Get_Tlv(QQAccount user)
        {
            var data = new BinaryWriter(new MemoryStream());

            data.Write(user.TXProtocol.BufSigClientAddr);
            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #26
0
        public WebQQClientTest(String user, String pwd, String wbUser, String wbPwd)
        {
            QQAccount account = new QQAccount();

            account.setUsername(user);
            account.setPassword(pwd);
            account.setWbUsername(wbUser);
            account.setWbPassword(wbPwd);
            client = new WebQQClient(new QQNotifyHandlerProxy(this), new ThreadActorDispatcher());
            client.setAccount(account);
        }
Beispiel #27
0
        public System.Byte[] Get_Tlv(QQAccount user)
        {
            var data = new BinaryWriter(new MemoryStream());

            data.BeWrite((System.UInt16)Encoding.UTF8.GetBytes(user.TXProtocol.BufComputerName).Length);
            data.Write(Encoding.UTF8.GetBytes(user.TXProtocol.BufComputerName));
            this.FillHead(this.Command);
            this.FillBody(data.ToByteArray(), data.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #28
0
        public System.Byte[] Get_Tlv(QQAccount user)
        {
            var bufTgt = user.TXProtocol.BufTgt;
            var buf    = new BinaryWriter(new MemoryStream());

            buf.Write(bufTgt);
            this.FillHead(this.Command);
            FillBody(buf.ToByteArray(), buf.BaseStream.Length);
            this.SetLength();
            return(this.GetBuffer());
        }
Beispiel #29
0
        /**
         * <p>doPollMsg.</p>
         */
        public void doPollMsg()
        {
            LoginModule login = (LoginModule)getContext().getModule(AbstractModule.Type.LOGIN);

            login.pollMsg(delegate(QQActionEvent evt) {
                // 回调通知事件函数
                if (evt.getType() == QQActionEvent.Type.EVT_OK)
                {
                    List <QQNotifyEvent> evts = (List <QQNotifyEvent>)evt.getTarget();
                    foreach (QQNotifyEvent e in evts)
                    {
                        getContext().fireNotify(e);
                    }

                    // 准备提交下次poll请求
                    QQSession session = getContext().getSession();
                    if (session.getState() == QQSession.State.ONLINE)
                    {
                        doPollMsg();
                    }
                    else if (session.getState() != QQSession.State.KICKED)
                    {
                        relogin();
                    }
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_ERROR)
                {
                    QQSession session = getContext().getSession();
                    QQAccount account = (QQAccount)getContext().getAccount();
                    session.setState(QQSession.State.OFFLINE);
                    account.setStatus(QQStatus.OFFLINE);
                    //因为自带了错误重试机制,如果出现了错误回调,表明已经超时多次均失败,这里直接返回网络错误的异常
                    QQException ex = (QQException)evt.getTarget();
                    QQWpfApplication1.action.QQException.QQErrorCode code = ex.getError();
                    if (code == QQWpfApplication1.action.QQException.QQErrorCode.INVALID_LOGIN_AUTH)
                    {
                        relogin();
                    }
                    else if (code == QQWpfApplication1.action.QQException.QQErrorCode.IO_ERROR || code == QQWpfApplication1.action.QQException.QQErrorCode.IO_TIMEOUT)
                    {
                        //粗线了IO异常,直接报网络错误
                        getContext().fireNotify(new QQNotifyEvent(QQNotifyEvent.Type.NET_ERROR, ex));
                    }
                    else
                    {
                        relogin();
                        doPollMsg();
                    }
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_RETRY)
                {
                }
            });
        }
Beispiel #30
0
        public System.Byte[] Get_Tlv(QQAccount user)
        {
            var data = new TLV0015().Get_Tlv(user);

            var encode = QQTea.Encrypt(data, user.TXProtocol.BufTgtgtKey);

            this.FillHead(this.Command);
            this.FillBody(encode, encode.Length);
            this.SetLength();
            return(this.GetBuffer());
        }