예제 #1
0
 public void OnFetchData(EB.Sparx.Response res, int reqInstanceID)
 {
     if (_ilrObject != null)
     {
         _ilrObject.OnFetchData(res, reqInstanceID);
     }
 }
예제 #2
0
        public void OnRequestResponse(EB.Sparx.Response res)
        {
            LoadingSpinner.Hide();
            if (res.sucessful)
            {
                var user = EB.Dot.Object("user", res.hashtable, null);
                if (user == null)
                {
                    Debug.LogError("Missing user object on set name!!!");
                }
                else
                {
                    LoginManager.Instance.LocalUser.Update(user);
                }

                MessageTemplateManager.ShowMessage(902045);
                DataLookupsCache.Instance.CacheData("name", InputLabel.value);
                string name = null;
                if (DataLookupsCache.Instance.SearchDataByID <string>(string.Format("mainlands.pl.{0}.un", LoginManager.Instance.LocalUserId), out name) && !string.IsNullOrEmpty(name))
                {
                    DataLookupsCache.Instance.CacheData(string.Format("mainlands.pl.{0}.un", LoginManager.Instance.LocalUserId), InputLabel.value);
                }

                if (isHadRename)
                {
                    FusionTelemetry.PostBuy(((int)FusionTelemetry.UseHC.hc_playername).ToString(), 1, (int)Hotfix_LT.Data.NewGameConfigTemplateManager.Instance.GetGameConfigValue("changeNameCost"));
                }
                controller.Close();
            }
            else
            {
                res.CheckAndShowModal();
            }
        }
예제 #3
0
 private void MergeDataHandler(EB.Sparx.Response response)
 {
     if (response != null && response.hashtable != null)
     {
         GameDataSparxManager.Instance.ProcessIncomingData(response.hashtable, true);
     }
 }
예제 #4
0
 public void OnFetchData(EB.Sparx.Response res, int reqInstanceID)
 {
     if (ilinstance != null)
     {
         ilinstance.OnFetchData(res, reqInstanceID);
     }
 }
예제 #5
0
        private void ProcessResult(EB.Sparx.Response response, System.Action <Hashtable> dataHandler)
        {
            dataHandler = dataHandler ?? new System.Action <Hashtable>(DefaultDataHandler);

            if (ExceptionFun != null && response.error != null) //处理Lostemp的异常
            {
                string error = response.error.ToString();
                if (ExceptionFun(error))
                {
                    ExceptionFun = null;
                    return;
                }
            }

            ExceptionFun = null;

            if (ProcessResponse(response))
            {
                dataHandler(response.hashtable);
            }
            else
            {
                dataHandler(null);
            }
        }
예제 #6
0
 public void OnNetworkError(EB.Sparx.Response result)
 {
     if (result.fatal)
     {
         DealError(result);
         return;
     }
 }
예제 #7
0
 private void ProcessResult(EB.Sparx.Response response, Action <Hashtable> dataHandler)
 {
     dataHandler = dataHandler ?? new Action <Hashtable>(DefaultDataHandler);
     if (ProcessResponse(response))
     {
         dataHandler(response.hashtable);
     }
     else
     {
         dataHandler(null);
     }
 }
예제 #8
0
 private void ProcessFriendResultEx(EB.Sparx.Response response, System.Action <EB.Sparx.Response> dataHandler)
 {
     dataHandler = dataHandler ?? new System.Action <EB.Sparx.Response>(DefaultDataHandler);
     if (ProcessResponse(response))
     {
         dataHandler(response);
     }
     else
     {
         dataHandler(null);
     }
 }
예제 #9
0
    public static bool GlobalErrorHandler(EB.Sparx.Response response, EB.Sparx.eResponseCode errCode)
    {
        if (response.fatal)
        {
            SparxHub.Instance.FatalError(response.localizedError);
        }
        else
        {
            ShowErrorDialogue(response.localizedError);
        }

        return(false);
    }
예제 #10
0
        public override bool ProcessResponse(EB.Sparx.Response response)
        {
            if (!response.sucessful)
            {
                EB.Sparx.eResponseCode errCode = CheckError(response.error.ToString());
                if (errCode != EB.Sparx.eResponseCode.Success && !ProcessError(response, errCode))
                {
                    EB.Debug.LogError("LoginAPI.ProcessResponse: request {0} failed, {1}", response.request.uri, response.error);
                    return(false);
                }
            }

            return(ProcessResult(response));
        }
예제 #11
0
        private bool OnApiError(EB.Sparx.Response response, EB.Sparx.eResponseCode errCode)
        {
            if (response.error.ToString() == "ID_SPARX_ERROR_TEMP_BANNED" || response.error.ToString() == "ID_SPARX_ERROR_BANNED")
            {
                response.ShowErrorModal(delegate()
                {
                    Hotfix_LT.Messenger.Raise <string, object, bool>(Hotfix_LT.EventName.ShowMenu, "EnterGameUI", null, true);
                    UIStack.Instance.HideLoadingScreen();
                });
                return(true);
            }

            return(false);
        }
예제 #12
0
        private void ProcessResult(EB.Sparx.Response response, System.Action <Hashtable> dataHandler)
        {
            dataHandler = dataHandler ?? new System.Action <Hashtable>(DefaultDataHandler);
            if (response.error != null)
            {
                if (!response.error.Equals("ID_NOT_IN_ACTIVITY_TIME"))
                {
                    EB.Debug.LogError(response.error);
                }
            }

            if (blockErrorFunc != null)
            {
                if (!blockErrorFunc(response))//默认允许的错误return true;
                {
                    if (ProcessResponse(response))
                    {
                        dataHandler(response.hashtable);
                    }
                    else
                    {
                        dataHandler(null);
                    }
                }
                else
                {
                    if (response.sucessful)
                    {
                        dataHandler(response.hashtable);
                    }
                    else
                    {
                        dataHandler(null);
                    }
                }
                blockErrorFunc = null;
            }
            else
            {
                if (ProcessResponse(response))
                {
                    dataHandler(response.hashtable);
                }
                else
                {
                    dataHandler(null);
                }
            }
        }
예제 #13
0
 private void ProcessInviteResult(EB.Sparx.Response response, System.Action <Hashtable> datahandler)
 {
     if (response.sucessful && response.result != null)
     {
         ProcessResult(response);
         datahandler(response.hashtable);
     }
     else if (!response.sucessful)
     {
         if (!ErrorHandle(response, CheckError(response.error.ToString())))
         {
             ProcessError(response, CheckError(response.error.ToString()));
         }
     }
 }
예제 #14
0
        private void ProcessResult(EB.Sparx.Response response, System.Action <Hashtable> dataHandler)
        {
            dataHandler = dataHandler ?? new System.Action <Hashtable>(DefaultDataHandler);

            if (response.error != null)
            {
                EB.Debug.LogError(response.error);
            }

            if (errorProcessFun != null)
            {
                if (!errorProcessFun(response))
                {
                    if (ProcessResponse(response))
                    {
                        dataHandler(response.hashtable);
                    }
                    else
                    {
                        dataHandler(null);
                    }
                }
                else
                {
                    if (response.sucessful)
                    {
                        dataHandler(response.hashtable);
                    }
                    else
                    {
                        dataHandler(null);
                    }
                }
                errorProcessFun = null;
            }
            else
            {
                if (ProcessResponse(response))
                {
                    dataHandler(response.hashtable);
                }
                else
                {
                    dataHandler(null);
                }
            }
        }
예제 #15
0
 public override void OnFetchData(EB.Sparx.Response res, int reqInstanceID)
 {
     if (mOnFetchData == null)
     {
         mOnFetchData = instance.Type.GetMethod("OnFetchData", 2);
     }
     if (mOnFetchData != null && !isOnFetchDataInvoking)
     {
         isOnFetchDataInvoking = true;
         appdomain.Invoke(mOnFetchData, instance, res, reqInstanceID);
         isOnFetchDataInvoking = false;
     }
     else
     {
         base.OnFetchData(res, reqInstanceID);
     }
 }
예제 #16
0
 private void ProcessError(EB.Sparx.Response response)
 {
     if (response.fatal)
     {
         EB.Debug.LogError("LTHeroBattleAPI.ProcessError: error {0} occur when request {1}", response.error,
                           response.request.uri);
         ProcessError(response, CheckError(response.error.ToString()));
     }
     else
     {
         EB.Sparx.eResponseCode errCode = CheckError(response.error.ToString());
         if (errCode != EB.Sparx.eResponseCode.Success && !ProcessError(response, errCode))
         {
             EB.Debug.LogError("LTHeroBattleAPI.ProcessError: request {0} failed, {1}", response.request.uri, response.error);
         }
     }
 }
예제 #17
0
    public static bool CheckAndShowModal(this EB.Sparx.Response response)
    {
        if (response.sucessful)
        {
            return(true);
        }

        if (response.fatal)
        {
            SparxHub.Instance.FatalError(response.localizedError);
        }
        else
        {
            ShowErrorDialogue(response.localizedError);
        }

        return(false);
    }
예제 #18
0
 private void OnSetScrollSkillResponse(EB.Sparx.Response result)
 {
     if (!result.sucessful)
     {
         if (result.error.Contains("ID_SPARX_NETWORK_ERROR"))
         {
             EB.Debug.LogWarning("CombatManager.SetScrollSkill===>Failed, retry! error: ID_SPARX_NETWORK_ERROR");
             endPoint.Service(_setscrollskill_request, OnSetScrollSkillResponse);
             return;
         }
         else
         {
             EB.Debug.LogError("CombatManager.SetScrollSkill - /combat/setSkill failed: {0}", result.error);
             OnNetworkError(result);
         }
     }
     _setscrollskill_request = null;
 }
예제 #19
0
    public static void SuspendHandler(EB.Sparx.Response response)
    {
        EB.Sparx.Request request = response.request;
        if (request.userData != null && request.userData is System.Action <EB.Sparx.Response> )
        {
            EB.Debug.LogWarning("SuspendHandler: callback with empty result, url = {0}", response.url);
            // callback empty result
            EB.Sparx.Response empty = new EB.Sparx.Response(request);
            empty.sucessful = true;
            Johny.HashtablePool.ReleaseRecursion(empty.hashtable);
            empty.hashtable = null;

            System.Action <EB.Sparx.Response> callback = request.userData as System.Action <EB.Sparx.Response>;
            if (System.Object.ReferenceEquals(callback.Target, null) || !callback.Target.Equals(null))
            {
                callback(empty);
            }
        }
    }
예제 #20
0
 private void ProcessLegionWarResult(EB.Sparx.Response response, System.Action <Hashtable> dataHandler)
 {
     dataHandler = dataHandler ?? new System.Action <Hashtable>(DefaultDataHandler);
     if (ErrorRedultFunc != null)
     {
         if (ErrorRedultFunc(response))//ture为允许的错误
         {
             if (response.sucessful)
             {
                 dataHandler(response.hashtable);
             }
             else
             {
                 dataHandler(null);
             }
         }
         else
         {
             if (ProcessResponse(response))
             {
                 dataHandler(response.hashtable);
             }
             else
             {
                 dataHandler(null);
             }
         }
     }
     else
     {
         if (ProcessResponse(response))
         {
             dataHandler(response.hashtable);
         }
         else
         {
             dataHandler(null);
         }
     }
 }
예제 #21
0
    private IEnumerator OnResponseCoroutine(EB.Sparx.Response response, System.Action <EB.Sparx.Response> callback = null, bool cacheData = true)
    {
        yield return(new WaitForSeconds(NetworkLatencySimulationDuration));        // simulate network latency

        if (cacheData)
        {
            IDictionary dataDic = response.result as IDictionary;

            if (dataDic == null)
            {
                dataDic = Johny.HashtablePool.Claim();
            }

            dataDic["serverError"] = response.error;
            HandleIncomingData(dataDic);
        }

        if (callback != null)
        {
            callback(response);
        }
    }
예제 #22
0
        private bool ErrorHandle(EB.Sparx.Response response, EB.Sparx.eResponseCode code)
        {
            string errorcode = response.error.ToString();

            switch (errorcode)
            {
            case "same ip or same device":
                MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, EB.Localizer.GetString("ID_INVITE_24"));    //相同ip或设备
                return(true);

            case "invalid code":
                MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, EB.Localizer.GetString("ID_INVITE_25"));    //错误邀请码
                return(true);

            case "used":
                MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, EB.Localizer.GetString("ID_INVITE_27"));    //只能绑定一次邀请码
                return(true);

            default:
                break;
            }
            return(false);
        }
예제 #23
0
 private void DealError(EB.Sparx.Response result)
 {
     if (result.error.ToString() == "ID_ERROR_NOT_IN_BATTLE")
     {
         LoadingSpinner.Hide();
         if (!LTCombatEventReceiver.Instance.IsBattleOver)
         {
             EB.Sparx.Request request2 = endPoint.Get("/playstate/getPlayState");
             endPoint.Service(request2, (result2) => {
                 if (result != null)
                 {
                     DataLookupsCache.Instance.CacheData(result2.hashtable);
                     LTCombatHudController.Instance.ShowBattleResultScreen(SceneLogic.BattleType, MainLandLogic.GetInstance().m_CombatOutCome, false);
                 }
             });
         }
     }
     else if (result.error.ToString().Contains("user is in another battle, combat_id = "))
     {
         BattleResultScreenController.DirectExitCombat();
     }
     else if (result.error.ToString().Contains("EndWrite failure") || result.error.ToString().Contains("ID_SPARX_ERROR_NOT_CONNECTED"))
     {
         SparxHub.Instance.Disconnect(false);
         MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, EB.Localizer.GetString("ID_SPARX_ERROR_NOT_CONNECTED"));
     }
     else if (result.error.ToString().Contains("socket hang up") || result.error.ToString().Contains("connection timed out"))
     {
         EB.Debug.LogError(result.error);
         SparxHub.Instance.Disconnect(false);
         MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, EB.Localizer.GetString("ID_SPARX_ERROR_NOT_CONNECTED"));
     }
     else
     {
         EB.Debug.LogError(result.error);
     }
 }
예제 #24
0
 private void DefaultDataHandler(EB.Sparx.Response friend)
 {
     EB.Debug.Log("FriendAPI.DefaultDataHandler: call default data handler");
 }
예제 #25
0
 public override void OnFetchData(EB.Sparx.Response res, int reqInstanceID)
 {
 }
예제 #26
0
        public void OnRequestPlayStateResponse(EB.Sparx.Response result)
        {
            if (result.sucessful)
            {
                string oldPlayState;
                DataLookupsCache.Instance.SearchDataByID <string>("playstate.state", out oldPlayState);
                Hashtable data         = result.hashtable;
                string    newPlayState = EB.Dot.String("playstate.state", data, "");
                EB.Debug.Log("OnRequestPlayStateResponse {0} {1}", oldPlayState, newPlayState);
                if (string.IsNullOrEmpty(newPlayState))
                {
                    EB.Debug.LogWarning("new PlayState is null");
                    return;
                }
                if (newPlayState == oldPlayState)
                {
                    IDictionary scenedata = null;
                    switch (newPlayState)
                    {
                    case "MainLand":
                    {
                        scenedata = EB.Dot.Object("mainlands", data, null);
                    }
                    break;

                    case "Campaign":
                    {
                        scenedata = EB.Dot.Object("campaigns", data, null);
                    }
                    break;

                    case "Combat":
                    {
                        if (SceneLogic.SceneState != SceneLogic.eSceneState.CombatLoop)
                        {
                            int cid;
                            DataLookupsCache.Instance.SearchIntByID("playstate.Combat.combat_id", out cid);
                            ResumeCombat(cid, delegate(Response r) { });
                        }
                    }
                    break;

                    default:
                    {
                        scenedata = null;
                    }
                    break;
                    }
                    if (scenedata != null)
                    {
                        DataLookupsCache.Instance.CacheData(data);
                        string scenetype = EB.Dot.String("scenetype", data, "");
                        NpcManager.Instance.MergeNpc(scenetype, scenedata);
                        PlayerManagerForFilter.Instance.MergePlayer(scenetype, scenedata);
                    }
                }
                else
                {
                    DataLookupsCache.Instance.CacheData(data);
                    EnterSceneByPlayState();
                    EB.Debug.LogWarning("PlayState is change");
                    return;
                }
            }
            else if (result.fatal)
            {
                SparxHub.Instance.FatalError(result.localizedError);
            }
        }
예제 #27
0
 public static void ShowErrorModal(this EB.Sparx.Response response, System.Action callback)
 {
     ShowErrorDialogue(response.localizedError, callback);
 }
예제 #28
0
 public static void ShowErrorModal(this EB.Sparx.Response response)
 {
     ShowErrorDialogue(response.localizedError);
 }
예제 #29
0
 private bool ErrorHandler(EB.Sparx.Response response, EB.Sparx.eResponseCode errCode)
 {
     return(false);
 }
예제 #30
0
 public virtual void OnFetchData(EB.Sparx.Response res, int reqInstanceID)
 {
 }