예제 #1
0
    private void OnInitMessageResponse(string response)
    {
#if UNITY_EDITOR
        if (Tracking)
        {
            PrintTrack(MethodBase.GetCurrentMethod().Name);
            PrintTrack("response: " + response);
        }
#endif

        _initializeAppMessageRef = null;

        if (string.IsNullOrEmpty(response))
        {
            FinishInit();
            return;
        }

        InitializeAppResponseMessage responseMessage = InitializeAppResponseMessage.FromJson(response);
        if (responseMessage == null)
        {
            FinishInit();
            return;
        }

        VersionNumber        currentApiVersionOnDevice = GetCurrentApiVersionOnDevice();
        CompareVersionNumber compareResult             =
            (CompareVersionNumber)currentApiVersionOnDevice.CompareTo(responseMessage.ApiVersion);

        if (compareResult == CompareVersionNumber.Equal)
        {
            _currentApiClientId = responseMessage.ApiclientId;
            _currentToken       = responseMessage.Token;
            FinishInit(responseMessage.ApiclientId, responseMessage.Token);
        }
        else
        {
            _updating = false;
            if (_onNewApiVersion != null)
            {
                _onNewApiVersion(currentApiVersionOnDevice, responseMessage.ApiVersion);
            }
        }
    }
예제 #2
0
    public static InitializeAppResponseMessage FromJson(string jsonString)
    {
        InitializeAppResponseMessage result = new InitializeAppResponseMessage();

        try
        {
            JsonData jsonData = JsonMapper.ToObject(jsonString);
            result.Status      = jsonData["status"].ToString();
            result.ApiVersion  = VersionNumber.Parse(jsonData["apiversion"].ToString());
            result.Token       = jsonData["token"].ToString();
            result.ApiclientId = int.Parse(jsonData["apiclientid"].ToString());
            return(result);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
            return(null);
        }
    }