Ejemplo n.º 1
0
 private void InternalManualOpen(string filename, GooglePlayGames.BasicApi.DataSource source, bool prefetchDataOnConflict, ConflictCallback conflictCallback, Action <SavedGameRequestStatus, ISavedGameMetadata> completedCallback)
 {
     this.mSnapshotManager.Open(filename, NativeSavedGameClient.AsDataSource(source), Types.SnapshotConflictPolicy.MANUAL, (Action <GooglePlayGames.Native.PInvoke.SnapshotManager.OpenResponse>)(response =>
     {
         if (!response.RequestSucceeded())
         {
             completedCallback(NativeSavedGameClient.AsRequestStatus(response.ResponseStatus()), (ISavedGameMetadata)null);
         }
         else if (response.ResponseStatus() == CommonErrorStatus.SnapshotOpenStatus.VALID)
         {
             completedCallback(SavedGameRequestStatus.Success, (ISavedGameMetadata)response.Data());
         }
         else if (response.ResponseStatus() == CommonErrorStatus.SnapshotOpenStatus.VALID_WITH_CONFLICT)
         {
             // ISSUE: object of a compiler-generated type is created
             // ISSUE: variable of a compiler-generated type
             NativeSavedGameClient.\u003CInternalManualOpen\u003Ec__AnonStorey142.\u003CInternalManualOpen\u003Ec__AnonStorey143 openCAnonStorey143 = new NativeSavedGameClient.\u003CInternalManualOpen\u003Ec__AnonStorey142.\u003CInternalManualOpen\u003Ec__AnonStorey143();
             // ISSUE: reference to a compiler-generated field
             openCAnonStorey143.\u003C\u003Ef__ref\u0024322 = this;
             // ISSUE: reference to a compiler-generated field
             openCAnonStorey143.original = response.ConflictOriginal();
             // ISSUE: reference to a compiler-generated field
             openCAnonStorey143.unmerged = response.ConflictUnmerged();
             // ISSUE: reference to a compiler-generated field
             // ISSUE: reference to a compiler-generated field
             // ISSUE: reference to a compiler-generated field
             // ISSUE: reference to a compiler-generated method
             openCAnonStorey143.resolver = new NativeSavedGameClient.NativeConflictResolver(this.mSnapshotManager, response.ConflictId(), openCAnonStorey143.original, openCAnonStorey143.unmerged, completedCallback, new Action(openCAnonStorey143.\u003C\u003Em__6E));
             if (!prefetchDataOnConflict)
             {
                 // ISSUE: reference to a compiler-generated field
                 // ISSUE: reference to a compiler-generated field
                 // ISSUE: reference to a compiler-generated field
                 conflictCallback((IConflictResolver)openCAnonStorey143.resolver, (ISavedGameMetadata)openCAnonStorey143.original, (byte[])null, (ISavedGameMetadata)openCAnonStorey143.unmerged, (byte[])null);
             }
             else
             {
                 // ISSUE: reference to a compiler-generated method
                 NativeSavedGameClient.Prefetcher prefetcher = new NativeSavedGameClient.Prefetcher(new Action <byte[], byte[]>(openCAnonStorey143.\u003C\u003Em__6F), completedCallback);
                 // ISSUE: reference to a compiler-generated field
                 this.mSnapshotManager.Read(openCAnonStorey143.original, new Action <GooglePlayGames.Native.PInvoke.SnapshotManager.ReadResponse>(prefetcher.OnOriginalDataRead));
                 // ISSUE: reference to a compiler-generated field
                 this.mSnapshotManager.Read(openCAnonStorey143.unmerged, new Action <GooglePlayGames.Native.PInvoke.SnapshotManager.ReadResponse>(prefetcher.OnUnmergedDataRead));
             }
         }
         else
         {
             Logger.e("Unhandled response status");
             completedCallback(SavedGameRequestStatus.InternalError, (ISavedGameMetadata)null);
         }
     }));
 }
Ejemplo n.º 2
0
        private static Types.DataSource AsDataSource(GooglePlayGames.BasicApi.DataSource source)
        {
            switch (source)
            {
            case GooglePlayGames.BasicApi.DataSource.ReadCacheOrNetwork:
                return(Types.DataSource.CACHE_OR_NETWORK);

            case GooglePlayGames.BasicApi.DataSource.ReadNetworkOnly:
                return(Types.DataSource.NETWORK_ONLY);

            default:
                throw new InvalidOperationException("Found unhandled DataSource: " + (object)source);
            }
        }
Ejemplo n.º 3
0
 public void FetchAllSavedGames(GooglePlayGames.BasicApi.DataSource source, Action <SavedGameRequestStatus, List <ISavedGameMetadata> > callback)
 {
     Misc.CheckNotNull <Action <SavedGameRequestStatus, List <ISavedGameMetadata> > >(callback);
     callback = NativeSavedGameClient.ToOnGameThread <SavedGameRequestStatus, List <ISavedGameMetadata> >(callback);
     this.mSnapshotManager.FetchAll(NativeSavedGameClient.AsDataSource(source), (Action <GooglePlayGames.Native.PInvoke.SnapshotManager.FetchAllResponse>)(response =>
     {
         if (!response.RequestSucceeded())
         {
             callback(NativeSavedGameClient.AsRequestStatus(response.ResponseStatus()), new List <ISavedGameMetadata>());
         }
         else
         {
             callback(SavedGameRequestStatus.Success, response.Data().Cast <ISavedGameMetadata>().ToList <ISavedGameMetadata>());
         }
     }));
 }
Ejemplo n.º 4
0
 public void FetchMatchingState(GooglePlayGames.BasicApi.DataSource source, QuestFetchFlags flags, Action <GooglePlayGames.BasicApi.ResponseStatus, List <IQuest> > callback)
 {
     Misc.CheckNotNull <Action <GooglePlayGames.BasicApi.ResponseStatus, List <IQuest> > >(callback);
     callback = CallbackUtils.ToOnGameThread <GooglePlayGames.BasicApi.ResponseStatus, List <IQuest> >(callback);
     this.mManager.FetchList(ConversionUtils.AsDataSource(source), (int)flags, (Action <GooglePlayGames.Native.PInvoke.QuestManager.FetchListResponse>)(response =>
     {
         GooglePlayGames.BasicApi.ResponseStatus responseStatus = ConversionUtils.ConvertResponseStatus(response.ResponseStatus());
         if (!response.RequestSucceeded())
         {
             callback(responseStatus, (List <IQuest>)null);
         }
         else
         {
             callback(responseStatus, response.Data().Cast <IQuest>().ToList <IQuest>());
         }
     }));
 }
Ejemplo n.º 5
0
 public void OpenWithManualConflictResolution(string filename, GooglePlayGames.BasicApi.DataSource source, bool prefetchDataOnConflict, ConflictCallback conflictCallback, Action <SavedGameRequestStatus, ISavedGameMetadata> completedCallback)
 {
     Misc.CheckNotNull <string>(filename);
     Misc.CheckNotNull <ConflictCallback>(conflictCallback);
     Misc.CheckNotNull <Action <SavedGameRequestStatus, ISavedGameMetadata> >(completedCallback);
     conflictCallback  = this.ToOnGameThread(conflictCallback);
     completedCallback = NativeSavedGameClient.ToOnGameThread <SavedGameRequestStatus, ISavedGameMetadata>(completedCallback);
     if (!NativeSavedGameClient.IsValidFilename(filename))
     {
         Logger.e("Received invalid filename: " + filename);
         completedCallback(SavedGameRequestStatus.BadInputError, (ISavedGameMetadata)null);
     }
     else
     {
         this.InternalManualOpen(filename, source, prefetchDataOnConflict, conflictCallback, completedCallback);
     }
 }
Ejemplo n.º 6
0
 public void Fetch(GooglePlayGames.BasicApi.DataSource source, string questId, Action <GooglePlayGames.BasicApi.ResponseStatus, IQuest> callback)
 {
     Misc.CheckNotNull <string>(questId);
     Misc.CheckNotNull <Action <GooglePlayGames.BasicApi.ResponseStatus, IQuest> >(callback);
     callback = CallbackUtils.ToOnGameThread <GooglePlayGames.BasicApi.ResponseStatus, IQuest>(callback);
     this.mManager.Fetch(ConversionUtils.AsDataSource(source), questId, (Action <GooglePlayGames.Native.PInvoke.QuestManager.FetchResponse>)(response =>
     {
         GooglePlayGames.BasicApi.ResponseStatus responseStatus = ConversionUtils.ConvertResponseStatus(response.ResponseStatus());
         if (!response.RequestSucceeded())
         {
             callback(responseStatus, (IQuest)null);
         }
         else
         {
             callback(responseStatus, (IQuest)response.Data());
         }
     }));
 }
Ejemplo n.º 7
0
        public void OpenWithAutomaticConflictResolution(string filename, GooglePlayGames.BasicApi.DataSource source, ConflictResolutionStrategy resolutionStrategy, Action <SavedGameRequestStatus, ISavedGameMetadata> callback)
        {
            Misc.CheckNotNull <string>(filename);
            Misc.CheckNotNull <Action <SavedGameRequestStatus, ISavedGameMetadata> >(callback);
            callback = NativeSavedGameClient.ToOnGameThread <SavedGameRequestStatus, ISavedGameMetadata>(callback);
            if (!NativeSavedGameClient.IsValidFilename(filename))
            {
                Logger.e("Received invalid filename: " + filename);
                callback(SavedGameRequestStatus.BadInputError, (ISavedGameMetadata)null);
            }
            else
            {
                this.OpenWithManualConflictResolution(filename, source, false, (ConflictCallback)((resolver, original, originalData, unmerged, unmergedData) =>
                {
                    switch (resolutionStrategy)
                    {
                    case ConflictResolutionStrategy.UseLongestPlaytime:
                        if (original.TotalTimePlayed >= unmerged.TotalTimePlayed)
                        {
                            resolver.ChooseMetadata(original);
                            break;
                        }
                        resolver.ChooseMetadata(unmerged);
                        break;

                    case ConflictResolutionStrategy.UseOriginal:
                        resolver.ChooseMetadata(original);
                        break;

                    case ConflictResolutionStrategy.UseUnmerged:
                        resolver.ChooseMetadata(unmerged);
                        break;

                    default:
                        Logger.e("Unhandled strategy " + (object)resolutionStrategy);
                        callback(SavedGameRequestStatus.InternalError, (ISavedGameMetadata)null);
                        break;
                    }
                }), callback);
            }
        }