Exemple #1
0
        private void OnKeyValueStoreDidChangeExternally(eCloudDataStoreValueChangeReason _reason, string[] _changedKeys)
        {
            // Update properties
            changedKeysCount = _changedKeys.Length;
            CloudServicesUtils.changedKeys = _changedKeys;

            // Send event
            switch (_reason)
            {
            case eCloudDataStoreValueChangeReason.SERVER:
                Fsm.Event(serverEvent);
                break;

            case eCloudDataStoreValueChangeReason.INITIAL_SYNC:
                Fsm.Event(initialSyncEvent);
                break;

            case eCloudDataStoreValueChangeReason.QUOTA_VIOLATION:
                Fsm.Event(quotaViolationEvent);
                break;

            case eCloudDataStoreValueChangeReason.STORE_ACCOUNT:
                Fsm.Event(storeAccountEvent);
                break;
            }
        }
Exemple #2
0
    private void OnKeyValueStoreChanged(eCloudDataStoreValueChangeReason _reason, string[] _changedKeys)
    {
        Debug.Log("Cloud key-value store has been changed.");
        Debug.Log(string.Format("Reason: {0}.", _reason));

        string message = "";

        switch (_reason)
        {
        case eCloudDataStoreValueChangeReason.INITIAL_SYNC:
            CloudInitComplete();
            message += "Initial Download from cloud server has not happend";
            break;

        case eCloudDataStoreValueChangeReason.SERVER:
            CloudInitComplete();
            message += "Someone else is using the same cloud service account";
            break;

        case eCloudDataStoreValueChangeReason.QUOTA_VIOLATION:
            message += "Quota violation";
            CloudInitComplete();
            break;

        case eCloudDataStoreValueChangeReason.STORE_ACCOUNT:
            CloudInitComplete();
            message += "STORE ACCOUNT";
            break;
        }

        Debug.Log(message);
    }
        protected void CloudKeyValueStoreDidChangeExternally(eCloudDataStoreValueChangeReason _reason, string[] _keys)
        {
            Console.Log(Constants.kDebugTag, "[CloudServices] Received key store value changed event.");

            if (KeyValueStoreDidChangeExternallyEvent != null)
            {
                KeyValueStoreDidChangeExternallyEvent(_reason, _keys);
            }
        }
Exemple #4
0
    private void OnKeyValueStoreChanged(eCloudDataStoreValueChangeReason _reason, string[] _changedKeys)
    {
        Debug.Log("Cloud key-value store has been changed.");

        if (_changedKeys != null)
        {
            Debug.Log(string.Format("Total keys changed: {0}.", _changedKeys.Length));
            Debug.Log(string.Format("Pick a value from old and new and set the value to cloud for resolving conflict."));
        }
    }
    private void OnKeyValueStoreChanged(eCloudDataStoreValueChangeReason _reason,
                                        string[] _changedKeys)
    {
        Debug.Log("Cloud key-value store has been changed.");
        Debug.Log(string.Format("Reason: {0}.", _reason));

        if (_changedKeys != null)
        {
            Debug.Log(string.Format("Total keys changed: {0}.", _changedKeys.Length));
            Debug.Log(string.Format("Pick a value from old and new and set the value to cloud for resolving conflict."));

            foreach (string oneKey in _changedKeys)
            {
                string corString = NPBinding.CloudServices.GetString(oneKey);

                PlayerDataManager.instance.m_LocalDataMng.SetString(oneKey, corString);

                // if (this.TryGetCorrectData(oneKey, out corString))
                // {
                //     NPBinding.CloudServices.SetString(
                //         oneKey, corString);
                // }
                // else
                // {
                //     // cannot check , let player choose one
                //     // TODO: show dialog

                // }
            }
            PlayerDataManager.instance.m_LocalDataMng.SaveData_All();

            // foreach (string _changedKey in _changedKeys)
            // {
            //     if (_changedKey.Equals(KEY_FOR_LONG)) // Shows example of resolving a conflict
            //     {
            //         long _newCloudLongValue = NPBinding.CloudServices.GetLong(_changedKey);
            //         Debug.Log(string.Format("New value for key: {0} is {1}. Old value is {2}", _changedKey, _newCloudLongValue, m_longValue));
            //         // Lets assume, we pick the bigger value and set it here.
            //         long _biggerValue = _newCloudLongValue > m_longValue ? _newCloudLongValue : m_longValue;

            //         NPBinding.CloudServices.SetLong(_changedKey, _biggerValue);

            //         Debug.Log(string.Format("Picking bigger value {0} and setting to cloud.", _biggerValue));
            //     }
            //     else if (_changedKey.Equals(kKeyForDoubleValue))
            //     {
            //         Debug.Log(string.Format("New value for key: {0} is {1}", _changedKey, NPBinding.CloudServices.GetDouble(_changedKey)));
            //     }

            // }
        }
    }
        protected override void CloudKeyValueStoreDidChangeExternally(string _dataStr)
        {
            IDictionary _dataDict            = (IDictionary)JSONUtility.FromJSON(_dataStr);
            IList       _changedKeysJSONList = _dataDict.GetIfAvailable <IList>(kKeyForValueChangedKeys);
            eCloudDataStoreValueChangeReason _changeReason = ConvertToUnityFormatChangeReason(_dataDict.GetIfAvailable <NSUbiquitousKeyValueStoreChangeReason>(kKeyForChangeReason));

            // Copy keys to string array
            string[] _changedKeysArray = null;

            if (_changedKeysJSONList != null)
            {
                _changedKeysArray = new string[_changedKeysJSONList.Count];

                _changedKeysJSONList.CopyTo(_changedKeysArray, 0);
            }

            // Invoke handler
            CloudKeyValueStoreDidChangeExternally(_changeReason, _changedKeysArray);
        }