Exemple #1
0
        internal void ProcessLoginTouchReply(LoginTouchReplyPacket loginTouchReplyPacket, LoginTouchPacket loginTouchPacket)
        {
            QQEventArgs<LoginTouchReplyPacket, LoginTouchPacket> e = new QQEventArgs<LoginTouchReplyPacket, LoginTouchPacket>(QQClient, loginTouchReplyPacket, loginTouchPacket);
            if (loginTouchReplyPacket.ReplyCode == ReplyCode.OK)
            {
                QQClient.LoginStatus = LoginStatus.Connected;
                if (loginTouchReplyPacket.IsRedirect)//转向
                {
                    if (Utils.Util.IsIPZero(loginTouchReplyPacket.RedirectIP))
                    {
                        //OnLoginRedirectNull(e);
                        QQClient.LogManager.Log("RedirectIp Is Zero!");
                        QQClient.LoginStatus = LoginStatus.Failed;
                    }
                    else
                    {
                        QQClient.LoginStatus = new LoginStatus("Redirect to" + Utils.Util.GetIpStringFromBytes(loginTouchReplyPacket.RedirectIP), "重定向到服务器" + Utils.Util.GetIpStringFromBytes(loginTouchReplyPacket.RedirectIP));
                        //OnLoginRedirect(e);
                        QQClient.LoginRedirect = true;
                        QQClient.ConnectionManager.ConnectionPool.Release(QQPort.Main.Name);
                        QQClient.LogManager.Log("Redirect to " + Utils.Util.GetIpStringFromBytes(loginTouchReplyPacket.RedirectIP));
                        string ipTemp = QQClient.LoginServerHost;
                        QQClient.LoginServerHost = Utils.Util.GetIpStringFromBytes(QQClient.ServerInfo.CSP_dwConnIP);
                        QQClient.ServerInfo.CSP_dwConnIP = Utils.Util.IpToBytes(ipTemp);
                        //重新登录
                        QQClient.Login();
                    }
                }
                else
                {
                    //将服务器返回的时间和IP存入QQClient等待使用
                    QQClient.ServerTime = loginTouchReplyPacket.ServerTime;
                    QQClient.ClientIP = loginTouchReplyPacket.ClientIP;
                    //0xba开始登陆
                    QQUser.QQKey.LoginRequestToken = loginTouchReplyPacket.Token;
                    OutPacket outPacket = new LoginRequestPacket(this.QQClient);
                    QQClient.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name);
                    //QQUser.QQKey = new QQKey(this.QQUser);
                    //QQClient.LoginManager.

                }

            }
            else
            { QQClient.LoginStatus = LoginStatus.Failed; }
        }
Exemple #2
0
 /// <summary>
 /// 登录
 /// </summary>
 public void Login()
 {
     if (string.IsNullOrEmpty(QQClient.LoginServerHost))
     {
         QQClient.LoginServerHost = GetNewServerIP();
     }
     //Check.Require(QQClient.LoginServerHost, "LoginServerHost", Check.NotNull);
     if (QQClient.LoginPort == 0)
     {
         if (QQUser.IsUdp)
         {
             QQClient.LoginPort = QQGlobal.QQ_PORT_UDP;
         }
         else
         {
             QQClient.LoginPort = QQGlobal.QQ_PORT_TCP;
         }
     }
     OutPacket outPacket = null;
     outPacket = new LoginTouchPacket(QQClient);
     QQClient.LogManager.Log("login...");
     QQClient.LoginStatus = LoginStatus.Connectting;
     QQClient.PacketManager.SendPacketTimeOut += new EventHandler<QQEventArgs<InPacket, OutPacket>>(PacketManager_SendPacketTimeOut);
     QQClient.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name);
 }