Exemple #1
0
    IEnumerator coroutine_SendProtocol(netData _pnet)
    {
        string _url = "";

        if (_pnet.protocolName == ProtocolName.CheckServer)         // 서버 상태 프로토콜
        {
            _url = DefineKey.CheckServerURL;
        }
        else
        {
            _url = string.Format("{0}{1}/{2}",
                                 URL, ProtocolForder[(int)((int)_pnet.protocolName / 10)],
                                 _pnet.protocolName.ToString());
        }
        www = _pnet.get_WebSend(_url);
        if (!isNetworking)
        {
            isNetworking = true;
            Loadmanager.instance.LoadingUI(isNetworking);

            if (waitCoroutine != null)
            {
                StopCoroutine(waitCoroutine);
            }



            webWorkingLog = string.Format("Try Request data {0}", _pnet.protocolName);
            UserEditor.Getsingleton.EditLog(string.Format("{0} networking : {1}", _pnet.protocolName, isNetworking));
        }
        yield return(www.SendWebRequest());

        try
        {
#if UNITY_EDITOR
            UserEditor.Getsingleton.EditLog(string.Format("return : <b><color=#28ff65>{0}</color></b>", www.downloadHandler.text));
#endif
            string _jsonData = www.downloadHandler.text;

            object _jsonObject = MiniJSON.Json.Deserialize(_jsonData);

            Dictionary <string, object> _dicInfo = (Dictionary <string, object>)_jsonObject;

            //반환데이터 오류에대한 bool 값 초기화
            webResponse.Resp_Error = false;

            //갱신 데이터 체크
            if (_pnet.protocolName == ProtocolName.CheckServer)
            {
                webResponse.ResponseWeb_CheckServer(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.GetServerList)
            {
                webResponse.ResponseWeb_GetServerList(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.GetVersion)
            {
                webResponse.ResponseWeb_GetVersion(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.GetServerTime)
            {
                webResponse.ResponseWeb_serverTime(_dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.GetConnectAdress)
            {
                webResponse.ResponseWeb_GetConnectAdress(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.GetReferenceDB)
            {
                TableDataManager.instance.Set_tableData(_dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.PostGetList)
            {
                webResponse.ResponseWeb_GetPostList_Data(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.UnitExpRanking)
            {
                webResponse.ResponseWeb_GetUnitExpRanking_Data(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.ClanList)
            {
                webResponse.ResponseWebClanList_Data(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.FriendList)
            {
                webResponse.ResponseWeb_FriendsList_Data(UserDataManager.instance.user, _dicInfo);
            }
            else if (_pnet.protocolName == ProtocolName.FriendGetInviteUrl)
            {
                webResponse.ResponseWeb_FriendInviteUrl_Data(UserDataManager.instance.user, _dicInfo, string.Format("{0}{1}/", URL, ProtocolForder[(int)((int)_pnet.protocolName / 10)]));
            }
            else if (_pnet.protocolName == ProtocolName.SetMemberChange)
            {
                webResponse.ResponseWeb_MemberChange(_dicInfo);
            }
            else
            {
                webResponse.Get_ListGainitem(_dicInfo);

                webWorkingLog = string.Format("complete {0} data", _pnet.protocolName);
#if UNITY_EDITOR
                UserEditor.Getsingleton.EditLog(webWorkingLog);
#endif
            }

            www = null;

            // 불러서 또 쏠거 있는지 체크하자
            Send_WebProtocol();


            //콜백함수가 있다면 콜백함수 부르자
            if (_pnet.del_result != null && !webResponse.Resp_Error)                //매서드가 널이 아니고 에러가 아니면
            {
                _pnet.del_result();
            }

            if (isWebException)
            {
                isWebException = false;
            }
        }
        catch (Exception e)
        {
            UserEditor.Getsingleton.EditLog(e);
            if (isWebException == false)
            {
                isWebException = true;

                //www 널로
                www = null;

                // 로딩바 끄기
                isNetworking = false;
                Loadmanager.instance.LoadingUI(isNetworking);


                Scene _scene = SceneManager.GetActiveScene();
                if (_scene.name == DefineKey.Main)                    //메인씬일때만
                {
                    Set_ProtocalError(_pnet.protocolName);
                    //User _user = UserDataManager.instance.user;
                    //if (_user.user_Users.UserID != 0)
                    //    popup.SetPopupMessage(string.Format("User ID : {0} \n\n {1}", _user.user_Users.UserID, Set_ProtocalError(_pnet.protocolName)));
                    //else
                    //    popup.SetPopupMessage(Set_ProtocalError(popup,_pnet.protocolName));

                    //popup.Set_addEventButton(goto_TitleUI);
                }
                else
                {
                    //팝업
                    UI_Popup_Notice popup = UI_Manager.Getsingleton.CreatAndGetPopup <UI_Popup_Notice>(UIPOPUP.POPUPNOTICE);
                    popup.Set_PopupTitleMessage("오류");
                    popup.SetPopupMessage(string.Format("Network Error,\n Please Restart SuddenGround App \n\n\nError : {0}  Network Error", _pnet.protocolName));
                    popup.Set_addEventButton(Application.Quit);
                }
            }
            else
            {
                //www 널로
                www = null;
                // exeption_gotoTitleUI();
            }
        }
    }