コード例 #1
0
ファイル: PlayFabManager.cs プロジェクト: mrdivdiz/bpvita
 public void UpdateUserData(Dictionary <string, string> data, UserDataPermission permission)
 {
     if (!this.initialized)
     {
         return;
     }
     base.StartCoroutine(this.UpdateUserDataInChunks(data, permission));
 }
コード例 #2
0
    public IEnumerator LogPlayerData(Dictionary <string, string> pairs, UserDataPermission permission = UserDataPermission.Private)
    {
        UpdateUserDataRequest req = new UpdateUserDataRequest();

        {
            req.Data       = pairs;
            req.Permission = permission;
        };

        Action <Action <UpdateUserDataResult>, Action <PlayFabError> > apiCall = (onsuccess, onError) =>
        {
            PlayFabClientAPI.UpdateUserData(req, onsuccess, onError);
        };

        yield return(ExecuteApiCallWithRetry(apiCall));
    }
コード例 #3
0
ファイル: PlayFabManager.cs プロジェクト: mrdivdiz/bpvita
 private void AddToPendingCloudCache(Dictionary <string, string> data, UserDataPermission permission)
 {
     if (this.pendingCloudData == null)
     {
         this.pendingCloudData = new Dictionary <string, PendingData>();
     }
     foreach (KeyValuePair <string, string> keyValuePair in data)
     {
         if (this.pendingCloudData.ContainsKey(keyValuePair.Key))
         {
             this.pendingCloudData[keyValuePair.Key].SetData(keyValuePair.Value, permission);
         }
         else
         {
             this.pendingCloudData.Add(keyValuePair.Key, new PendingData(keyValuePair.Value, permission));
         }
     }
 }
コード例 #4
0
ファイル: PlayFabManager.cs プロジェクト: mrdivdiz/bpvita
 private bool UpdateDictionaryChunk(int maxChunkSize, UserDataPermission newPermission)
 {
     if (this.IsSendingChunkCache)
     {
         if (this.sendCache.Count == 0)
         {
             this.IsSendingChunkCache = false;
         }
         return(this.pendingCloudData.Count > 0);
     }
     this.sendCachePermission = newPermission;
     this.IsSendingChunkCache = true;
     this.sendCache.Clear();
     Dictionary <string, PendingData> .KeyCollection keys = this.pendingCloudData.Keys;
     string[] array = new string[this.pendingCloudData.Count];
     keys.CopyTo(array, 0);
     for (int i = 0; i < array.Length; i++)
     {
         if (i >= maxChunkSize || this.pendingCloudData[array[i]].Permission != this.sendCachePermission)
         {
             break;
         }
         this.sendCache.Add(array[i], this.pendingCloudData[array[i]].Data);
         this.pendingCloudData.Remove(array[i]);
     }
     if (this.sendCache.Count > 0)
     {
         UpdateUserDataRequest request = new UpdateUserDataRequest
         {
             Data       = this.sendCache,
             Permission = new UserDataPermission?(this.sendCachePermission)
         };
         PlayFabClientAPI.UpdateUserData(request, new Action <UpdateUserDataResult>(this.OnUserDataUpdated), new Action <PlayFabError>(this.OnUserDataUpdateError), null, null);
     }
     else
     {
         this.IsSendingChunkCache = false;
     }
     return(this.pendingCloudData.Count > 0);
 }
コード例 #5
0
ファイル: PlayFabManager.cs プロジェクト: mrdivdiz/bpvita
    private IEnumerator UpdateUserDataInChunks(Dictionary <string, string> data, UserDataPermission permission)
    {
        this.AddToPendingCloudCache(data, permission);
        if (this.IsSendingChunkCache || this.waitingForMoreData)
        {
            if (this.waitingForMoreData)
            {
                this.waitForSeconds = 2f;
            }
            yield break;
        }
        this.waitingForMoreData = true;
        this.waitForSeconds     = 2f;
        while (this.waitForSeconds > 0f)
        {
            this.waitForSeconds -= GameTime.RealTimeDelta;
            yield return(null);
        }
        this.waitingForMoreData = false;
        EventManager.Send(new PlayFabEvent(PlayFabEvent.Type.UserDataUploadStarted));
        UserDataPermission sendPermission = UserDataPermission.Private;

        while (this.Initialized && this.UpdateDictionaryChunk(10, sendPermission))
        {
            while (this.IsSendingChunkCache)
            {
                yield return(null);
            }
            if (sendPermission == UserDataPermission.Private)
            {
                sendPermission = UserDataPermission.Public;
            }
            else
            {
                sendPermission = UserDataPermission.Private;
            }
        }
        EventManager.Send(new PlayFabEvent(PlayFabEvent.Type.UserDataUploadEnded));
        yield break;
    }
コード例 #6
0
ファイル: PlayFabManager.cs プロジェクト: mrdivdiz/bpvita
 public void SetData(string data, UserDataPermission permission)
 {
     this.Data       = data;
     this.Permission = permission;
 }
コード例 #7
0
ファイル: PlayFabManager.cs プロジェクト: mrdivdiz/bpvita
 public PendingData(string data, UserDataPermission permission)
 {
     this.SetData(data, permission);
 }
コード例 #8
0
 public void LogPlayerDataAsync(string key, string value, UserDataPermission permission = UserDataPermission.Private)
 {
     StartCoroutine(LogPlayerData(new Dictionary <string, string> {
         { key, value }
     }));
 }