예제 #1
0
        private IEnumerator AuthenticateParallel(object authData)
        {
            endPoint.AddData("stoken", Hub.ApiEndPoint.GetData("stoken"));

            bool?  prelogin     = null;
            object preloginData = null;

            EB.Debug.Log("HuaweiSDKManager.Authenticate: Start PreLogin");
            api.PreLogin(delegate(string preloginError, object preloginResult)
            {
                if (!string.IsNullOrEmpty(preloginError))
                {
                    prelogin = false;

                    var url = Dot.String("url", preloginResult, null);
                    if (!string.IsNullOrEmpty(url))
                    {
                        Hub.Config.LoginConfig.Listener.OnUpdateRequired(url);
                        return;
                    }
                    else
                    {
                        Hub.FatalError(preloginError);
                        return;
                    }
                }

                prelogin     = true;
                preloginData = preloginResult;
                EB.Debug.Log("HuaweiSDKManager.Authenticate: PreLogin Success");
            });

            while (!prelogin.HasValue)
            {
                yield return(null);
            }

            if (!prelogin.Value)
            {
                yield break;
            }

            var salt = Dot.String("salt", preloginData, string.Empty);

            yield return(Coroutines.Run(Protect.CalculateHmac(salt, delegate(string challenge)
            {
                var securityData = new Hashtable();
                securityData["salt"] = salt;
                securityData["chal"] = challenge;

                EB.Debug.Log("HuaweiSDKManager.Authenticate: Start Login");
                api.Login("huawei", new Hashtable()
                {
                    { "huawei", authData }
                }, securityData, delegate(string loginError, object loginResult)
                {
                    if (!string.IsNullOrEmpty(loginError))
                    {
                        Hub.FatalError(loginError);
                        return;
                    }

                    EB.Debug.Log("HuaweiSDKManager.Authenticate: Login success");
                });
            })));
        }