Esempio n. 1
0
 public void onError(PackResult ret)
 {
     Log.e("Network", string.Concat(new object[] { "pack.onError, cmd = ", (CmdConst)this.mCmdID, " seq = ", this.mSeqID, ", ret = ", ret }));
     if (this.mCompleted != null)
     {
         PackEventArgs args = new PackEventArgs
         {
             result = ret
         };
         if (this.isAutoAuthPack())
         {
             SessionPackMgr.setAuthStatus(0);
         }
         else
         {
             if (((this.mCmdID == 1) || (this.mCmdID == 0x20)) || (this.mCmdID == 0x1f) || (this.mCmdID == 0xb2))
             {
                 SessionPackMgr.setSessionKey(null);
                 SessionPackMgr.getAccount().reset();
                 SessionPackMgr.setAuthStatus(0);
             }
             //Deployment.get_Current().get_Dispatcher().BeginInvoke(new SessionPackCompletedDelegate(this.mCompleted.Invoke), new object[] { this, args });
             SessionPackCompletedDelegate spd = new SessionPackCompletedDelegate(this.mCompleted.Invoke);
             spd.BeginInvoke(this, args, null, null);
         }
     }
 }
Esempio n. 2
0
        public void onSuccess()
        {
            Log.i("Network", string.Concat(new object[] { "pack.onSuccess, cmd = ", (CmdConst)this.mCmdID, " seq = ", this.mSeqID }));
            if (this.mCompleted != null)
            {
                PackEventArgs args = new PackEventArgs
                {
                    result = PackResult.SUCCESS
                };
                //Deployment.get_Current().get_Dispatcher().BeginInvoke(
                //new SessionPackCompletedDelegate(this.mCompleted.Invoke), new object[] { this, args };
                SessionPackCompletedDelegate dd = new SessionPackCompletedDelegate(this.mCompleted.Invoke);

                dd.BeginInvoke(this, args, null, null);
                //AsyncCallback bak = new SessionPackCompletedDelegate(this.mCompleted.Invoke);
                //System.Runtime.Remoting.Messaging.AsyncResult result = dd.BeginInvoke(null,this.mCompleted.Invoke,null, new object[] { this, args });
            }
        }
Esempio n. 3
0
 private static void onAutoAuthCompleted(object sender, PackEventArgs e)
 {
     if (!e.isSuccess())
     {
         Log.e("Network", "auto auth failed .");
     }
     else
     {
         SessionPack     pack            = sender as SessionPack;
         NewAuthResponse mResponseObject = (NewAuthResponse)pack.mResponseObject;
         NewAuthRequest  mRequestObject  = (NewAuthRequest)pack.mRequestObject;
         RetConst        ret             = (RetConst)mResponseObject.BaseResponse.Ret;
         if (ret == RetConst.MM_ERR_IDC_REDIRECT)
         {
             if (mIDCAutoAuthCount < 3)
             {
                 mIDCAutoAuthCount++;
                 SessionPackMgr.putToHead(makeAutoAuthPack(2));
                 return;
             }
             Log.e("Network", "Redirect IDC too much, auto auth failed!");
         }
         mIDCAutoAuthCount = 0;
         switch (ret)
         {
         case RetConst.MM_OK:
         case RetConst.MM_ERR_CRITICALUPDATE:
         case RetConst.MM_ERR_RECOMMENDEDUPDATE:
         {
             Log.i("Network", "auto auth success. ");
             Log.i("Network", "New AutoAuthTicket = " + SessionPackMgr.getAccount().AutoAuthKey);
             Util.WriteLog("New AutoAuthTicket = " + SessionPackMgr.getAccount().AutoAuthKey);
             // Account account = AccountMgr.getCurAccount();
             // account.bytesSessionkey = mResponseObject.SessionKey.ToByteArray();
             // account.nUin = mResponseObject.Uin;
             //  account.dbLastSessionKeyTimeStamp = Util.getNowSeconds();
             //  account.bytesA2Key = mResponseObject.A2Key.Buffer.ToByteArray();
             SessionPackMgr.getAccount().SessionKey = mResponseObject.SessionKey.ToByteArray();
             AccountMgr.updateAccount();
             EventCenter.postEvent(EventConst.ON_NETSCENE_AUTOAUTH_SUCCESS, mResponseObject, null);
             return;
         }
         }
         if (ret == RetConst.MM_ERR_NEED_VERIFY)
         {
             if ((mResponseObject.ImgBuf == null) || (mResponseObject.ImgSid == null))
             {
                 Log.e("Network", "NEED_VERIFY_USER, but ImgSid or ImgBuf is null");
                 EventCenter.postEvent(EventConst.ON_NETSCENE_AUTOAUTH_ERR, ret, null);
             }
             else
             {
                 //VerifyCodeArgs args = new VerifyCodeArgs {
                 //    mImageSid = mResponseObject.ImgSid.String,
                 //    mImageBuf = mResponseObject.ImgBuf.Buffer.ToByteArray()
                 //};
                 Log.e("Network", "auto auth failed, need verify,  sid = " + "args.mImageSid");
                 //EventCenter.postEvent(EventConst.ON_NETSCENE_AUTH_NEEDVERIFY, args, null);
             }
         }
         else if (ret == RetConst.MM_ERR_QQ_OK_NEED_MOBILE)
         {
             Log.i("Network", "autoAuth Need Mobile veryfy ret = " + ret.ToString());
             EventCenter.postEvent(EventConst.ON_NETSCENE_AUTOAUTH_ERR, ret, mResponseObject.BindMobile.String);
         }
         else
         {
             Log.e("Network", "auto auth failed, result = " + mResponseObject.BaseResponse.ErrMsg.String);
             EventCenter.postEvent(EventConst.ON_NETSCENE_AUTOAUTH_ERR, ret, null);
         }
     }
 }