Beispiel #1
0
 protected override void DealConnectClose(ApolloResult result)
 {
     if (this.DisconnectEvent != null)
     {
         this.DisconnectEvent(this);
     }
 }
Beispiel #2
0
 public override ApolloShareResult FromString(string src)
 {
     char[] separator = new char[] { '&' };
     foreach (string str in src.Split(separator))
     {
         char[]   chArray2  = new char[] { '=' };
         string[] strArray3 = str.Split(chArray2);
         if (strArray3.Length > 1)
         {
             if (strArray3[0].CompareTo("Platform") == 0)
             {
                 this.platform = (ApolloPlatform)int.Parse(strArray3[1]);
             }
             else if (strArray3[0].CompareTo("nResult") == 0)
             {
                 this.result = (ApolloResult)int.Parse(strArray3[1]);
             }
             else if (strArray3[0].CompareTo("szDescription") == 0)
             {
                 this.drescription = strArray3[1];
             }
             else if (strArray3[0].CompareTo("szExt") == 0)
             {
                 this.extInfo = strArray3[1];
             }
         }
     }
     return(this);
 }
Beispiel #3
0
 public ApolloRealNameAuthResult()
 {
     this.Platform  = ApolloPlatform.None;
     this.Ret       = ApolloResult.Unknown;
     this.ErrorCode = -1;
     this.Desc      = string.Empty;
 }
Beispiel #4
0
    public ApolloAccountInfo GetAccountInfo(bool refreshToken = false)
    {
        ApolloAccountInfo accountInfo = new ApolloAccountInfo();

        if (ApolloConfig.platform == ApolloPlatform.None)
        {
            accountInfo.OpenId   = ApolloConfig.CustomOpenId;
            accountInfo.Platform = ApolloPlatform.None;
            return(accountInfo);
        }
        ApolloResult record = this.accountService.GetRecord(ref accountInfo);

        if (record == ApolloResult.Success)
        {
            Debug.Log("GetAccountInfo Success");
            if (this.m_CurPlatform != accountInfo.Platform)
            {
                ApolloConfig.platform = this.m_CurPlatform = accountInfo.Platform;
            }
            return(accountInfo);
        }
        if (((record == ApolloResult.TokenInvalid) && (accountInfo != null)) && ((accountInfo.Platform == ApolloPlatform.Wechat) && refreshToken))
        {
            Debug.Log("try to refresh token");
            this.accountService.RefreshAtkEvent += new RefreshAccessTokenHandler(this.OnRefreshAccessTokenEvent);
            this.accountService.RefreshAccessToken();
            return(null);
        }
        Debug.Log(string.Format("GetRecord Fail result is {0}", record));
        Debug.Log(string.Format("current platform is {0}", (accountInfo != null) ? ((object)accountInfo.Platform) : ((object)0)));
        return(null);
    }
Beispiel #5
0
        //MARK: Connect Operations
        public void Connect(string ip, uint port, ProtocolType type, string dhp = null)
        {
            _type = type;
            Log(string.Format("Connect ProtocolType.{0} ip:{1} port:{2} dhp:{3}", type, ip, port, dhp));

            _sequence = 0;
            _protocol = new ProtocolPackage();

            if (dhp == null)
            {
                dhp = _dhp;
            }

            if (type == ProtocolType.UDP)
            {
                _connector = IApollo.Instance.CreateApolloConnection(ApolloPlatform.None, "lwip://" + ip + ":" + port);
            }
            else
            {
                _connector = IApollo.Instance.CreateApolloConnection(ApolloPlatform.None, "tcp://" + ip + ":" + port);
            }

            _connector.ConnectEvent    += new ConnectEventHandler(ApolloConnectHandler);
            _connector.RecvedDataEvent += new RecvedDataHandler(ApolloRecievedDataEventHandler);
            _connector.ErrorEvent      += new ConnectorErrorEventHandler(ApolloErrorHandler);
            _connector.DisconnectEvent += new DisconnectEventHandler(ApolloDisconnectHandler);
            _connector.ReconnectEvent  += new ReconnectEventHandler(ApolloReconnectHandler);

            _connector.SetSecurityInfo(ApolloEncryptMethod.None, ApolloKeyMaking.None, dhp);
            ApolloResult r = _connector.Connect();

            Log(string.Format("Connect... ApolloResult.{0}", r));
        }
Beispiel #6
0
    public ApolloAccountInfo GetAccountInfo(bool refreshToken = false)
    {
        ApolloAccountInfo accountInfo = new ApolloAccountInfo();

        if (ApolloConfig.platform == ApolloPlatform.None)
        {
            accountInfo.OpenId   = ApolloConfig.CustomOpenId;
            accountInfo.Platform = ApolloPlatform.None;
            return(accountInfo);
        }
        ApolloResult record = this.accountService.GetRecord(ref accountInfo);

        if (record == ApolloResult.Success)
        {
            if ((this.CurPlatform == ApolloPlatform.None) && (this.CurPlatform != accountInfo.Platform))
            {
                ApolloConfig.platform = this.CurPlatform = accountInfo.Platform;
            }
            return(accountInfo);
        }
        if (((record == ApolloResult.TokenInvalid) && (accountInfo != null)) && ((accountInfo.Platform == ApolloPlatform.Wechat) && refreshToken))
        {
            this.accountService.RefreshAtkEvent -= new RefreshAccessTokenHandler(this.OnRefreshAccessTokenEvent);
            this.accountService.RefreshAtkEvent += new RefreshAccessTokenHandler(this.OnRefreshAccessTokenEvent);
            this.accountService.RefreshAccessToken();
            return(null);
        }
        return(null);
    }
Beispiel #7
0
 public ApolloResult Send(TalkerMessageType type, TalkerCommand command, IPackable request, ApolloMessage message)
 {
     if (command == null || request == null)
     {
         return(ApolloResult.InvalidArgument);
     }
     byte[] array = null;
     if (message == null)
     {
         message = new ApolloMessage();
     }
     if (message.PackRequestData(command, request, out array, type))
     {
         ADebug.Log(string.Concat(new object[]
         {
             "Sending:",
             command,
             " data size:",
             array.Length
         }));
         ApolloResult apolloResult = this.connector.WriteData(array, -1);
         if (apolloResult == ApolloResult.Success && message.Handler != null)
         {
             ApolloMessageManager.Instance.SeqMessageCollection.Add(message.SeqNum, message);
         }
         return(apolloResult);
     }
     ADebug.LogError("Send: " + command + " msg.PackRequestDat error");
     return(ApolloResult.InnerError);
 }
Beispiel #8
0
        private void onAccessTokenRefresedProc(string msg)
        {
            ADebug.Log("onAccessTokenRefresedProc: " + msg);
            ApolloStringParser     parser    = new ApolloStringParser(msg);
            ListView <ApolloToken> tokenList = null;
            ApolloResult           @int      = (ApolloResult)parser.GetInt("Result");

            if (@int == ApolloResult.Success)
            {
                string src = parser.GetString("tokens");
                if (src != null)
                {
                    src = ApolloStringParser.ReplaceApolloString(src);
                    ADebug.Log("onAccessTokenRefresedProc tokens:" + src);
                    if ((src != null) && (src.Length > 0))
                    {
                        char[]   separator = new char[] { ',' };
                        string[] strArray  = src.Split(separator);
                        tokenList = new ListView <ApolloToken>();
                        foreach (string str2 in strArray)
                        {
                            string      str3 = ApolloStringParser.ReplaceApolloString(ApolloStringParser.ReplaceApolloString(str2));
                            ApolloToken item = new ApolloToken();
                            item.FromString(str3);
                            ADebug.Log(string.Format("onAccessTokenRefresedProc str:{0} |||||| {1}   |||||{2}", str3, item.Type, item.Value));
                            tokenList.Add(item);
                        }
                    }
                }
            }
            if (this.RefreshAtkEvent != null)
            {
                this.RefreshAtkEvent(@int, tokenList);
            }
        }
Beispiel #9
0
        private void OnReconnectProc(string msg)
        {
            ADebug.Log("c#:OnReconnectProc: " + msg);
            ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
            ApolloResult       @int = (ApolloResult)apolloStringParser.GetInt("Result", 6);

            if (@int == ApolloResult.Success)
            {
                this.Connected = true;
            }
            else
            {
                this.Connected = false;
            }
            if (this.ReconnectEvent != null)
            {
                try
                {
                    this.ReconnectEvent(@int);
                }
                catch (Exception exception)
                {
                    ADebug.LogException(exception);
                }
            }
            else
            {
                ADebug.Log("OnReconnectProc ReconnectEvent is null");
            }
        }
Beispiel #10
0
        public ApolloResult ReadUdpData(out byte[] buffer, out int realLength)
        {
            buffer     = null;
            realLength = 0;
            if (!this.Connected)
            {
            }
            if (this.tempReadBuffer == null)
            {
                this.tempReadBuffer = new byte[ApolloCommon.ApolloInfo.MaxMessageBufferSize];
            }
            int          num          = this.tempReadBuffer.Length;
            ApolloResult apolloResult = ApolloConnector.apollo_connector_readUdpData(base.ObjectId, this.tempReadBuffer, ref num);

            if (apolloResult == ApolloResult.Success)
            {
                if (num == 0)
                {
                    ADebug.LogError("ReadUdpData empty len==0");
                    return(ApolloResult.Empty);
                }
                buffer     = this.tempReadBuffer;
                realLength = num;
            }
            return(apolloResult);
        }
Beispiel #11
0
    public ApolloAccountInfo GetAccountInfo(bool refreshToken = false)
    {
        ApolloAccountInfo apolloAccountInfo = new ApolloAccountInfo();

        if (ApolloConfig.platform == null)
        {
            apolloAccountInfo.set_OpenId(ApolloConfig.CustomOpenId);
            apolloAccountInfo.set_Platform(0);
            return(apolloAccountInfo);
        }
        ApolloResult record = this.accountService.GetRecord(ref apolloAccountInfo);

        if (record == null)
        {
            if (this.CurPlatform == null && this.CurPlatform != apolloAccountInfo.get_Platform())
            {
                ApolloConfig.platform = (this.CurPlatform = apolloAccountInfo.get_Platform());
            }
            return(apolloAccountInfo);
        }
        if (record == 16 && apolloAccountInfo != null && apolloAccountInfo.get_Platform() == 1 && refreshToken)
        {
            this.accountService.remove_RefreshAtkEvent(new RefreshAccessTokenHandler(this.OnRefreshAccessTokenEvent));
            this.accountService.add_RefreshAtkEvent(new RefreshAccessTokenHandler(this.OnRefreshAccessTokenEvent));
            this.accountService.RefreshAccessToken();
            return(null);
        }
        return(null);
    }
Beispiel #12
0
        private void OnConnectProc(string msg)
        {
            ADebug.Log("c#:OnConnectProc: " + msg);
            if (string.IsNullOrEmpty(msg))
            {
                ADebug.LogError("OnConnectProc msg is null");
                return;
            }
            ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
            ApolloResult       @int = (ApolloResult)apolloStringParser.GetInt("Result", 6);

            this.LoginInfo = apolloStringParser.GetObject <ApolloLoginInfo>("LoginInfo");
            if (@int == ApolloResult.Success)
            {
                this.Connected = true;
            }
            else
            {
                this.Connected = false;
            }
            ADebug.Log(string.Concat(new object[]
            {
                "c#:OnConnectProc: ",
                @int,
                " loginfo:",
                this.LoginInfo
            }));
            if (this.LoginInfo != null && this.LoginInfo.AccountInfo != null && this.LoginInfo.AccountInfo.TokenList != null)
            {
                ADebug.Log(string.Concat(new object[]
                {
                    "C# logininfo| platform:",
                    this.LoginInfo.AccountInfo.Platform,
                    " openid:",
                    this.LoginInfo.AccountInfo.OpenId,
                    " tokensize:",
                    this.LoginInfo.AccountInfo.TokenList.Count,
                    " pf:",
                    this.LoginInfo.AccountInfo.Pf,
                    " pfkey:",
                    this.LoginInfo.AccountInfo.PfKey
                }));
            }
            if (this.ConnectEvent != null)
            {
                try
                {
                    this.ConnectEvent(@int, this.LoginInfo);
                }
                catch (Exception exception)
                {
                    ADebug.LogException(exception);
                }
            }
            else
            {
                ADebug.Log("OnConnectProc ConnectEvent is null");
            }
        }
Beispiel #13
0
 private void onDisconnectEvent(ApolloResult result)
 {
     if (result == ApolloResult.Success)
     {
         this.connected = false;
         this.DealConnectClose(result);
     }
 }
Beispiel #14
0
        private void DispatchConnectEvent(ConnectEventType type, ApolloResult result)
        {
            Log(string.Format("ConnectEventType.{0} ApolloResult.{1}", type, result));

            if (_connectHandler != null)
            {
                _connectHandler(type, result);
            }
        }
Beispiel #15
0
 private void onLoginProc(string msg)
 {
     BugLocateLogSys.Log("ApolloAccountService onLoginProc:" + msg);
     if (!string.IsNullOrEmpty(msg))
     {
         ApolloStringParser apolloStringParser = new ApolloStringParser(msg);
         ApolloAccountInfo  apolloAccountInfo  = null;
         ApolloResult       @int = (ApolloResult)apolloStringParser.GetInt("Result");
         BugLocateLogSys.Log("ApolloAccountService onLoginProc: result" + @int);
         if (@int == ApolloResult.Success)
         {
             apolloAccountInfo = apolloStringParser.GetObject <ApolloAccountInfo>("AccountInfo");
             if (apolloAccountInfo != null && apolloAccountInfo.TokenList != null)
             {
                 BugLocateLogSys.Log(string.Concat(new object[]
                 {
                     "C# onLoginProc|",
                     @int,
                     " platform:",
                     apolloAccountInfo.Platform,
                     " openid:",
                     apolloAccountInfo.OpenId,
                     " tokensize:",
                     apolloAccountInfo.TokenList.Count,
                     " pf:",
                     apolloAccountInfo.Pf,
                     " pfkey:",
                     apolloAccountInfo.PfKey
                 }));
             }
             else
             {
                 BugLocateLogSys.Log("parser.GetObject<ApolloAccountInfo>() return null");
                 Debug.LogError("parser.GetObject<ApolloAccountInfo>() return null");
             }
         }
         else
         {
             BugLocateLogSys.Log("C# onLoginProc error:" + @int);
             DebugHelper.Assert(false, "C# onLoginProc error:" + @int);
         }
         Debug.LogWarning(string.Format("LoginEvent:{0}", this.LoginEvent));
         if (this.LoginEvent != null)
         {
             try
             {
                 this.LoginEvent(@int, apolloAccountInfo);
             }
             catch (Exception ex)
             {
                 DebugHelper.Assert(false, "onLoginProc:" + ex);
                 BugLocateLogSys.Log("onLoginProc catch exception :" + ex.get_Message() + "|" + ex.ToString());
             }
         }
     }
 }
Beispiel #16
0
        public override void ReadFrom(ApolloBufferReader reader)
        {
            int platform = 0;
            int ret      = 0;

            reader.Read(ref platform);
            reader.Read(ref ret);
            reader.Read(ref this.ErrorCode);
            reader.Read(ref this.Desc);
            this.Platform = (ApolloPlatform)platform;
            this.Ret      = (ApolloResult)ret;
        }
Beispiel #17
0
        public ApolloResult GetRecord(ref ApolloAccountInfo pAccountInfo)
        {
            StringBuilder builder = new StringBuilder(0x1000);
            ApolloResult  result  = apollo_account_getRecord(base.ObjectId, builder, 0x1000);
            string        src     = builder.ToString();

            ADebug.Log(string.Concat(new object[] { "GetRecord:", result, ", ", src }));
            if (src.Length > 0)
            {
                pAccountInfo.FromString(src);
            }
            return(result);
        }
Beispiel #18
0
        protected override void DealConnectError(ApolloResult result)
        {
            this.lastResult = result;
            this.reconPolicy.StartPolicy(result);
            List <KeyValuePair <string, string> > events = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()),
                new KeyValuePair <string, string>("status", "1"),
                new KeyValuePair <string, string>("type", "platform"),
                new KeyValuePair <string, string>("errorCode", result.ToString())
            };

            Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_SvrConnectFail", events, true);
        }
Beispiel #19
0
        protected override void DealConnectFail(ApolloResult result, ApolloLoginInfo loginInfo)
        {
            this.reconPolicy.StartPolicy(result);
            MonoSingleton <Reconnection> .instance.QueryIsRelayGaming(result);

            List <KeyValuePair <string, string> > events = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()),
                new KeyValuePair <string, string>("status", "1"),
                new KeyValuePair <string, string>("type", "challenge"),
                new KeyValuePair <string, string>("errorCode", result.ToString())
            };

            Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_SvrConnectFail", events, true);
        }
Beispiel #20
0
    public void Login(ApolloPlatform platform, ulong uin = 0, string pwd = null)
    {
        switch (platform)
        {
        case ApolloPlatform.None:
        {
            if (ApolloConfig.CustomOpenId == null)
            {
            }
            ApolloResult result = NoneAccountService.Initialize(new NoneAccountInitInfo(ApolloConfig.CustomOpenId));
            if (result == ApolloResult.Success)
            {
                break;
            }
            List <KeyValuePair <string, string> > events = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("g_version", CVersion.GetAppVersion()),
                new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()),
                new KeyValuePair <string, string>("platform", Singleton <ApolloHelper> .GetInstance().CurPlatform.ToString()),
                new KeyValuePair <string, string>("openid", "NULL")
            };
            float num = Time.time - Singleton <CLoginSystem> .GetInstance().m_fLoginClickTime;

            events.Add(new KeyValuePair <string, string>("totaltime", num.ToString()));
            events.Add(new KeyValuePair <string, string>("errorcode", result.ToString()));
            events.Add(new KeyValuePair <string, string>("error_msg", "null"));
            Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_Login_MSDKClientAuth", events, true);

            Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloResult>(EventID.ApolloHelper_Login_Failed, result);

            return;
        }

        case ApolloPlatform.WTLogin:
            Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloResult>(EventID.ApolloHelper_Login_Failed, ApolloResult.Empty);

            return;
        }
        ApolloConfig.Uin      = uin;
        ApolloConfig.Password = pwd;
        ApolloConfig.platform = this.CurPlatform = platform;
        if ((ApolloConfig.platform == ApolloPlatform.None) && this.IsNoneModeSupport)
        {
            Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloAccountInfo>(EventID.ApolloHelper_Login_Success, this.GetAccountInfo(false));
        }
        else
        {
            this.OnLogin(platform);
        }
    }
Beispiel #21
0
 private void onReconnectEvent(ApolloResult result)
 {
     if (this.connector != null)
     {
         if (result == ApolloResult.Success)
         {
             this.connected = true;
             this.DealConnectSucc();
         }
         else
         {
             this.DealConnectFail(result, null);
         }
     }
 }
Beispiel #22
0
 private void onConnectEvent(ApolloResult result, ApolloLoginInfo loginInfo)
 {
     if (this.connector != null)
     {
         if (result == ApolloResult.Success)
         {
             this.connected = true;
             this.DealConnectSucc();
         }
         else
         {
             this.DealConnectFail(result, loginInfo);
         }
     }
 }
        protected override void DealConnectError(ApolloResult result)
        {
            this.lastResult = result;
            this.reconPolicy.StartPolicy(result, 10);
            List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();

            list.Add(new KeyValuePair <string, string>("g_version", CVersion.GetAppVersion()));
            list.Add(new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()));
            list.Add(new KeyValuePair <string, string>("platform", Singleton <ApolloHelper> .GetInstance().CurPlatform.ToString()));
            list.Add(new KeyValuePair <string, string>("openid", "NULL"));
            list.Add(new KeyValuePair <string, string>("status", "0"));
            list.Add(new KeyValuePair <string, string>("type", "platform"));
            list.Add(new KeyValuePair <string, string>("errorCode", result.ToString()));
            Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_SvrConnectFail", list, true);
        }
Beispiel #24
0
    private void OnLoginEvent(ApolloResult loginResult, ApolloAccountInfo loginfo)
    {
        Debug.Log("OnLoginEvent called");
        this.m_IsSwitchToLoginPlatform = false;
        if (loginResult == ApolloResult.Success)
        {
            if (loginfo != null)
            {
                if ((this.m_LastOpenID != null) && (loginfo.OpenId != this.m_LastOpenID))
                {
                    Singleton <CUIManager> .GetInstance().OpenMessageBox(Singleton <CTextManager> .GetInstance().GetText("Common_Login_Different_Account_Tip_Force"), enUIEventID.Login_Change_Account_Yes, false);

                    return;
                }
                Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloAccountInfo>(EventID.ApolloHelper_Login_Success, loginfo);
            }
        }
        else if (loginResult == ApolloResult.UserCancel)
        {
            Debug.Log("Login Fail. User cancel");
            BugLocateLogSys.Log(string.Format("Login Fail. User cancel", new object[0]));
            Singleton <EventRouter> .GetInstance().BroadCastEvent(EventID.ApolloHelper_Login_Canceled);
        }
        else
        {
            Debug.Log(string.Format("Login Fail. Error code is {0}", loginResult));
            BugLocateLogSys.Log(string.Format("Login Fail. Error code is {0}", loginResult));
            List <KeyValuePair <string, string> > events = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()),
                new KeyValuePair <string, string>("status", "1"),
                new KeyValuePair <string, string>("errorcode", loginResult.ToString())
            };
            Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_PlatformLogin", events, true);

            Singleton <EventRouter> .GetInstance().BroadCastEvent(EventID.ApolloHelper_Login_Failed);
        }
        if (this.accountService != null)
        {
            this.accountService.LoginEvent -= new AccountLoginHandle(this.OnLoginEvent);
        }
        else
        {
            BugLocateLogSys.Log("accountService == null");
        }
        this.m_IsLoginEventHandlerRegistered = false;
        this.m_IsLoginReturn = true;
        BugLocateLogSys.Log("LoginEvent Thread:" + Thread.CurrentThread.ManagedThreadId);
    }
Beispiel #25
0
        protected override void DealConnectFail(ApolloResult result, ApolloLoginInfo loginInfo)
        {
            this.reconPolicy.StartPolicy(result, 6);
            MonoSingleton <Reconnection> .get_instance().QueryIsRelayGaming(result);

            List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();

            list.Add(new KeyValuePair <string, string>("g_version", CVersion.GetAppVersion()));
            list.Add(new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()));
            list.Add(new KeyValuePair <string, string>("platform", Singleton <ApolloHelper> .GetInstance().CurPlatform.ToString()));
            list.Add(new KeyValuePair <string, string>("openid", "NULL"));
            list.Add(new KeyValuePair <string, string>("status", "0"));
            list.Add(new KeyValuePair <string, string>("type", "challenge"));
            list.Add(new KeyValuePair <string, string>("errorCode", result.ToString()));
            Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_SvrConnectFail", list, true);
        }
Beispiel #26
0
    public void Login(ApolloPlatform platform, ulong uin = 0uL, string pwd = null)
    {
        switch (platform)
        {
        case 0:
        {
            if (ApolloConfig.CustomOpenId == null)
            {
            }
            ApolloResult apolloResult = NoneAccountService.Initialize(new NoneAccountInitInfo(ApolloConfig.CustomOpenId));
            if (apolloResult != null)
            {
                List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();
                list.Add(new KeyValuePair <string, string>("g_version", CVersion.GetAppVersion()));
                list.Add(new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()));
                list.Add(new KeyValuePair <string, string>("platform", Singleton <ApolloHelper> .GetInstance().CurPlatform.ToString()));
                list.Add(new KeyValuePair <string, string>("openid", "NULL"));
                list.Add(new KeyValuePair <string, string>("totaltime", (Time.time - Singleton <CLoginSystem> .GetInstance().m_fLoginClickTime).ToString()));
                list.Add(new KeyValuePair <string, string>("errorCode", apolloResult.ToString()));
                list.Add(new KeyValuePair <string, string>("error_msg", "null"));
                Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_Login_MSDKClientAuth", list, true);

                Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloResult>(EventID.ApolloHelper_Login_Failed, apolloResult);

                return;
            }
            break;
        }

        case 3:
            Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloResult>(EventID.ApolloHelper_Login_Failed, 7);

            return;
        }
        ApolloConfig.Uin      = uin;
        ApolloConfig.Password = pwd;
        this.CurPlatform      = platform;
        ApolloConfig.platform = platform;
        if (ApolloConfig.platform == null && this.IsNoneModeSupport)
        {
            Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloAccountInfo>(EventID.ApolloHelper_Login_Success, this.GetAccountInfo(false));
        }
        else
        {
            this.OnLogin(platform);
        }
    }
Beispiel #27
0
    public void Login(ApolloPlatform platform, ulong uin = 0, string pwd = null)
    {
        switch (platform)
        {
        case ApolloPlatform.None:
        {
            if (ApolloConfig.CustomOpenId == null)
            {
                Debug.Log(string.Format("Custom OpenId is Empty! current platform{0}", platform));
            }
            ApolloResult result = NoneAccountService.Initialize(new NoneAccountInitInfo(ApolloConfig.CustomOpenId));
            if (result != ApolloResult.Success)
            {
                Debug.Log(string.Format("login apollo result is {0}! current platform{1}", result, platform));
                List <KeyValuePair <string, string> > events = new List <KeyValuePair <string, string> > {
                    new KeyValuePair <string, string>("WorldID", MonoSingleton <TdirMgr> .GetInstance().SelectedTdir.logicWorldID.ToString()),
                    new KeyValuePair <string, string>("status", "1"),
                    new KeyValuePair <string, string>("errorcode", result.ToString())
                };
                Singleton <ApolloHelper> .GetInstance().ApolloRepoertEvent("Service_PlatformLogin", events, true);

                Singleton <EventRouter> .GetInstance().BroadCastEvent(EventID.ApolloHelper_Login_Failed);

                return;
            }
            Debug.Log(string.Format("Set login by none platform success", result, platform));
            break;
        }

        case ApolloPlatform.WTLogin:
            Singleton <EventRouter> .GetInstance().BroadCastEvent(EventID.ApolloHelper_Login_Failed);

            return;
        }
        ApolloConfig.Uin      = uin;
        ApolloConfig.Password = pwd;
        ApolloConfig.platform = this.m_CurPlatform = platform;
        if (ApolloConfig.platform == ApolloPlatform.None)
        {
            Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloAccountInfo>(EventID.ApolloHelper_Login_Success, this.GetAccountInfo(false));
        }
        else
        {
            this.OnLogin(platform);
        }
    }
Beispiel #28
0
        private void OnAccountLogoutProc(int ret)
        {
            ApolloResult result = (ApolloResult)ret;

            ADebug.Log("OnAccountLogoutProc result:" + result);
            if (this.LogoutEvent != null)
            {
                try
                {
                    this.LogoutEvent(result);
                }
                catch (Exception exception)
                {
                    ADebug.LogError("OnAccountLogoutProc:" + exception);
                }
            }
        }
Beispiel #29
0
        private void OnAccountInitializeProc(int ret, byte[] buf)
        {
            ApolloResult result = (ApolloResult)ret;

            ADebug.Log("OnAccountInitializeProc result:" + result);
            if (this.InitializeEvent != null)
            {
                try
                {
                    this.InitializeEvent(result, null);
                }
                catch (Exception exception)
                {
                    ADebug.LogError("OnAccountInitializeProc:" + exception);
                }
            }
        }
Beispiel #30
0
 private void OnRefreshAccessTokenEvent(ApolloResult result, ListView <ApolloToken> tokenList)
 {
     if (result == ApolloResult.Success)
     {
         ApolloAccountInfo accountInfo = this.GetAccountInfo(false);
         if ((accountInfo != null) && this.JudgeLoginAccountInfo(ref accountInfo))
         {
             Singleton <EventRouter> .GetInstance().BroadCastEvent <ApolloAccountInfo>(EventID.ApolloHelper_Login_Success, accountInfo);
         }
     }
     else if (tokenList != null)
     {
         for (int i = 0; i < tokenList.Count; i++)
         {
         }
     }
 }