Exemplo n.º 1
0
    IEnumerator ConnectServer()
    {
        _txtState.text = "Connecting to getway server...";
        yield return(new WaitForSeconds(1));

        isNeedUpdateVersion = false;
        int _currentVersion = PlayerPrefs.GetInt("CURRENT_VERSION", 1);

        yield return(StartCoroutine(ServerAdapter.CheckServer(result =>
        {
            if (result.StartsWith("Error"))
            {
                isHaveError = true;
                dataError = result;
            }
            else
            {
                var N = CoreLib.JSON.Parse(result);
                if (N["version"] != null)
                {
                    int _serverVersion = N["version"].AsInt;
                    if (_serverVersion != _currentVersion)
                    {
                        isNeedUpdateVersion = true;
                    }
                }
                if (N["notify"] != null)
                {
                    _dataNotify = N["notify"].Value;
                    //if (_serverVersion > 1)
                    _myPopupNotify.SetActive(true);
                    //else _btnNotifyPopup.SetActive(false);
                }
                if (N["status"] != null)
                {
                    if (N["status"].Value.Equals("maintain"))
                    {
                        isHaveError = true;
                        dataError = "Server is maintaining. Please come back later!";
                    }
                }
            }
        })));
    }