Exemple #1
0
            public void ChooseMetadata(ISavedGameMetadata chosenMetadata)
            {
                var convertedMetadata = chosenMetadata as AndroidSnapshotMetadata;

                if (convertedMetadata != mOriginal && convertedMetadata != mUnmerged)
                {
                    Logger.e("Caller attempted to choose a version of the metadata that was not part " +
                             "of the conflict");
                    mCompleteCallback(SavedGameRequestStatus.BadInputError, null);
                    return;
                }

                using (var task = mSnapshotsClient.Call <AndroidJavaObject>(
                           "resolveConflict", mConflict.Call <string>("getConflictId"), convertedMetadata.JavaSnapshot))
                {
                    AndroidTaskUtils.AddOnSuccessListener <AndroidJavaObject>(
                        task,
                        dataOrConflict => mRetryFileOpen());

                    mAndroidSavedGameClient.AddOnFailureListenerWithSignOut(
                        task,
                        exception =>
                    {
                        Logger.d("ChooseMetadata failed: " + exception.Call <string>("toString"));
                        var status = mAndroidSavedGameClient.mAndroidClient.IsAuthenticated()
                                ? SavedGameRequestStatus.InternalError
                                : SavedGameRequestStatus.AuthenticationError;
                        mCompleteCallback(status, null);
                    }
                        );
                }
            }
 void DoGetAnotherServerAuthCode(bool reAuthenticateIfNeeded, Action <string> callback)
 {
     try
     {
         using (var bridgeClass = new AndroidJavaClass(HelperFragmentClass))
             using (var currentActivity = AndroidHelperFragment.GetActivity())
                 using (var pendingResult = bridgeClass.CallStatic <AndroidJavaObject>(
                            "fetchToken",
                            currentActivity,
                            /* silent= */ reAuthenticateIfNeeded,
                            /* requestAuthCode= */ true,
                            /* requestEmail= */ false,
                            /* requestIdToken= */ false,
                            webClientId,
                            /* forceRefresh= */ false,
                            oauthScopes.ToArray(),
                            /* hidePopups= */ true,
                            /* accountName= */ ""))
                 {
                     pendingResult.Call("setResultCallback", new ResultCallbackProxy(
                                            tokenResult => { callback(tokenResult.Call <string>("getAuthCode")); }));
                 }
     }
     catch (Exception e)
     {
         Logger.e("Exception launching token request: " + e.Message);
         Logger.e(e.ToString());
     }
 }
Exemple #3
0
        void PopulateUser(uint authGeneration, PlayerManager.FetchSelfResponse response)
        {
            Logger.d("Populating User");

            if (authGeneration != mAuthGeneration)
            {
                Logger.d("Received user callback after signout occurred, ignoring");
                return;
            }

            lock (AuthStateLock)
            {
                if (response.Status() != Status.ResponseStatus.VALID &&
                    response.Status() != Status.ResponseStatus.VALID_BUT_STALE)
                {
                    Logger.e("Error retrieving user, signing out");
                    var localCallbacks = mPendingAuthCallbacks;
                    mPendingAuthCallbacks = null;

                    if (localCallbacks != null)
                    {
                        InvokeCallbackOnGameThread(localCallbacks, false);
                    }
                    SignOut();
                    return;
                }

                mUser    = response.Self().AsPlayer();
                mFriends = null;
            }
            Logger.d("Found User: "******"Maybe finish for User");
            MaybeFinishAuthentication();
        }
        // called from game thread
        public Participant GetParticipant(string id)
        {
            Logger.d("AndroidRtmpClient.GetParticipant: " + id);

            if (!CheckConnectedRoom("GetParticipant"))
            {
                return(null);
            }

            List <Participant> allParticipants;

            lock (mParticipantListsLock) {
                allParticipants = mAllParticipants;
            }

            if (allParticipants == null)
            {
                Logger.e("RtmpGetParticipant called without a valid room!");
                return(null);
            }

            foreach (Participant p in allParticipants)
            {
                if (p.ParticipantId.Equals(id))
                {
                    return(p);
                }
            }

            Logger.e("Participant not found in room! id: " + id);
            return(null);
        }
Exemple #5
0
        public void ReadBinaryData(ISavedGameMetadata metadata,
                                   Action <SavedGameRequestStatus, byte[]> completedCallback)
        {
            Misc.CheckNotNull(metadata);
            Misc.CheckNotNull(completedCallback);
            completedCallback = ToOnGameThread(completedCallback);

            var convertedMetadata = metadata as AndroidSnapshotMetadata;

            if (convertedMetadata == null)
            {
                Logger.e("Encountered metadata that was not generated by this ISavedGameClient");
                completedCallback(SavedGameRequestStatus.BadInputError, null);
                return;
            }

            if (!convertedMetadata.IsOpen)
            {
                Logger.e("This method requires an open ISavedGameMetadata.");
                completedCallback(SavedGameRequestStatus.BadInputError, null);
                return;
            }

            var data = convertedMetadata.JavaContents.Call <byte[]>("readFully");

            if (data == null)
            {
                completedCallback(SavedGameRequestStatus.BadInputError, null);
            }
            else
            {
                completedCallback(SavedGameRequestStatus.Success, data);
            }
        }
Exemple #6
0
        public void OpenWithAutomaticConflictResolution(string filename, DataSource source,
                                                        ConflictResolutionStrategy resolutionStrategy,
                                                        Action <SavedGameRequestStatus, ISavedGameMetadata> completedCallback)
        {
            Misc.CheckNotNull(filename);
            Misc.CheckNotNull(completedCallback);
            var prefetchDataOnConflict        = false;
            ConflictCallback conflictCallback = null;

            completedCallback = ToOnGameThread(completedCallback);

            if (conflictCallback == null)
            {
                conflictCallback = (resolver, original, originalData, unmerged, unmergedData) =>
                {
                    switch (resolutionStrategy)
                    {
                    case ConflictResolutionStrategy.UseOriginal:
                        resolver.ChooseMetadata(original);
                        return;

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

                    case ConflictResolutionStrategy.UseLongestPlaytime:
                        if (original.TotalTimePlayed >= unmerged.TotalTimePlayed)
                        {
                            resolver.ChooseMetadata(original);
                        }
                        else
                        {
                            resolver.ChooseMetadata(unmerged);
                        }

                        return;

                    default:
                        Logger.e("Unhandled strategy " + resolutionStrategy);
                        completedCallback(SavedGameRequestStatus.InternalError, null);
                        return;
                    }
                }
            }
            ;

            conflictCallback = ToOnGameThread(conflictCallback);

            if (!IsValidFilename(filename))
            {
                Logger.e("Received invalid filename: " + filename);
                completedCallback(SavedGameRequestStatus.BadInputError, null);
                return;
            }

            InternalOpen(filename, source, resolutionStrategy, prefetchDataOnConflict, conflictCallback,
                         completedCallback);
        }
Exemple #7
0
        public void CommitUpdate(ISavedGameMetadata metadata, SavedGameMetadataUpdate updateForMetadata,
                                 byte[] updatedBinaryData, Action <SavedGameRequestStatus, ISavedGameMetadata> callback)
        {
            Misc.CheckNotNull(metadata);
            Misc.CheckNotNull(updatedBinaryData);
            Misc.CheckNotNull(callback);

            callback = ToOnGameThread(callback);

            var convertedMetadata = metadata as AndroidSnapshotMetadata;

            if (convertedMetadata == null)
            {
                Logger.e("Encountered metadata that was not generated by this ISavedGameClient");
                callback(SavedGameRequestStatus.BadInputError, null);
                return;
            }

            if (!convertedMetadata.IsOpen)
            {
                Logger.e("This method requires an open ISavedGameMetadata.");
                callback(SavedGameRequestStatus.BadInputError, null);
                return;
            }

            if (!convertedMetadata.JavaContents.Call <bool>("writeBytes", updatedBinaryData))
            {
                Logger.e("This method requires an open ISavedGameMetadata.");
                callback(SavedGameRequestStatus.BadInputError, null);
            }

            using (var convertedMetadataChange = AsMetadataChange(updateForMetadata))
                using (var task = mSnapshotsClient.Call <AndroidJavaObject>("commitAndClose", convertedMetadata.JavaSnapshot,
                                                                            convertedMetadataChange))
                {
                    AndroidTaskUtils.AddOnSuccessListener <AndroidJavaObject>(
                        task,
                        /* disposeResult= */ false,
                        snapshotMetadata =>
                    {
                        Debug.Log("commitAndClose.succeed");
                        callback(SavedGameRequestStatus.Success,
                                 new AndroidSnapshotMetadata(snapshotMetadata, /* contents= */ null));
                    });

                    AddOnFailureListenerWithSignOut(
                        task,
                        exception =>
                    {
                        Debug.Log("commitAndClose.failed: " + exception.Call <string>("toString"));
                        var status = mAndroidClient.IsAuthenticated()
                            ? SavedGameRequestStatus.InternalError
                            : SavedGameRequestStatus.AuthenticationError;
                        callback(status, null);
                    });
                }
        }
        /// <summary>
        /// Returns the user's avatar URL if they have one.
        /// </summary>
        /// <returns>
        /// The URL, or <code>null</code> if the user is not authenticated or does not have
        /// an avatar.
        /// </returns>
        public string GetUserImageUrl()
        {
            if (!IsAuthenticated())
            {
                Logger.e("GetUserImageUrl can only be called after authentication.");
                return null;
            }

            return mClient.GetUserImageUrl();
        }
        /// <summary>
        /// Returns the user's display name.
        /// </summary>
        /// <returns>
        /// The user display name (e.g. "Bruno Oliveira")
        /// </returns>
        public string GetUserDisplayName()
        {
            if (!IsAuthenticated())
            {
                Logger.e("GetUserDisplayName can only be called after authentication.");
                return string.Empty;
            }

            return mClient.GetUserDisplayName();
        }
        /// <summary>
        /// Returns the user's Google ID.
        /// </summary>
        /// <returns>
        /// The user's Google ID. No guarantees are made as to the meaning or format of
        /// this identifier except that it is unique to the user who is signed in.
        /// </returns>
        public string GetUserId()
        {
            if (!IsAuthenticated())
            {
                Logger.e("GetUserId() can only be called after authentication.");
                return "0";
            }

            return mClient.GetUserId();
        }
        /// <summary>
        /// Loads the user information if available.
        /// <param name="userIds">The user ids to look up</param>
        /// <param name="callback">The callback</param>
        /// </summary>
        public void LoadUsers(string[] userIds, Action<IUserProfile[]> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("GetUserId() can only be called after authentication.");
                callback(new IUserProfile[0]);
            }

            mClient.LoadUsers(userIds, callback);
        }
        /// <summary>
        /// Returns the achievement corresponding to the passed achievement identifier.
        /// </summary>
        /// <returns>
        /// The achievement corresponding to the identifer. <code>null</code> if no such
        /// achievement is found or if the user is not authenticated.
        /// </returns>
        /// <param name="achievementId">
        /// The identifier of the achievement.
        /// </param>
        public Achievement GetAchievement(string achievementId)
        {
            if (!IsAuthenticated())
            {
                Logger.e("GetAchievement can only be called after authentication.");
                return null;
            }

            return mClient.GetAchievement(achievementId);
        }
 // checks that the room is connected, and warn otherwise
 private bool CheckConnectedRoom(string method)
 {
     if (mRoom == null || !mDeliveredRoomConnected)
     {
         Logger.e("Method " + method + " called without a connected room. " +
                  "You must create or join a room AND wait until you get the " +
                  "OnRoomConnected(true) callback.");
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// Shows the standard Google Play Games achievements user interface,
        /// which allows the player to browse their achievements.
        /// </summary>
        /// <param name="callback">If non-null, the callback is invoked when
        /// the achievement UI is dismissed</param>
        public void ShowAchievementsUI(Action<UIStatus> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("ShowAchievementsUI can only be called after authentication.");
                return;
            }

            Logger.d("ShowAchievementsUI callback is "  + callback);
            mClient.ShowAchievementsUI(callback);
        }
        /// <summary>
        /// Shows the leaderboard UI and calls the specified callback upon
        /// completion.
        /// </summary>
        /// <param name="lbId">leaderboard ID, can be null meaning all leaderboards.</param>
        /// <param name="span">Timespan to display scores in the leaderboard.</param>
        /// <param name="callback">Callback to call.  If null, nothing is called.</param>
        public void ShowLeaderboardUI(string lbId, LeaderboardTimeSpan span,
            Action<UIStatus> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("ShowLeaderboardUI can only be called after authentication.");
                callback(UIStatus.NotAuthorized);
                return;
            }

            Logger.d("ShowLeaderboardUI, lbId=" + lbId + " callback is " + callback);
            mClient.ShowLeaderboardUI(lbId, span, callback);
        }
        public void LoadMoreScores(ScorePageToken token, int rowCount,
            Action<LeaderboardScoreData> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("LoadMoreScores can only be called after authentication.");
                callback(new LeaderboardScoreData(token.LeaderboardId,
                    ResponseStatus.NotAuthorized));
                return;
            }

            mClient.LoadMoreScores(token, rowCount, callback);
        }
       /// <summary>
       /// Loads the friends that also play this game.  See loadConnectedPlayers.
       /// </summary>
       /// <param name="callback">Callback.</param>
        public void LoadFriends(ILocalUser user, Action<bool> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("LoadScores can only be called after authentication.");
                if (callback != null)
                {
                    callback(false);
                }
            }

            mClient.LoadFriends(callback);
        }
Exemple #18
0
        ///<summary></summary>
        /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.SetStepsAtLeast"/>
        public void SetStepsAtLeast(string achId, int steps, Action <bool> callback)
        {
            Misc.CheckNotNull(achId);
            callback = AsOnGameThreadCallback(callback);

            InitializeGameServices();

            var achievement = GetAchievement(achId);

            if (achievement == null)
            {
                Logger.e("Could not increment, no achievement with ID " + achId);
                callback(false);
                return;
            }

            if (!achievement.IsIncremental)
            {
                Logger.e("Could not increment, achievement with ID " +
                         achId + " is not incremental");
                callback(false);
                return;
            }

            if (steps < 0)
            {
                Logger.e("Attempted to increment by negative steps");
                callback(false);
                return;
            }

            GameServices().AchievementManager().SetStepsAtLeast(achId, Convert.ToUInt32(steps));
            GameServices().AchievementManager().Fetch(achId, rsp =>
            {
                if (rsp.Status() == Status.ResponseStatus.VALID)
                {
                    mAchievements.Remove(achId);
                    mAchievements.Add(achId, rsp.Achievement().AsAchievement());
                    callback(true);
                }
                else
                {
                    Logger.e("Cannot refresh achievement " + achId + ": " +
                             rsp.Status());
                    callback(false);
                }
            });
        }
        /// <summary>
        /// Loads the scores using the provided parameters.
        /// </summary>
        /// <param name="leaderboardId">Leaderboard identifier.</param>
        /// <param name="start">Start either top scores, or player centered.</param>
        /// <param name="rowCount">Row count. the number of rows to return.</param>
        /// <param name="collection">Collection. social or public</param>
        /// <param name="timeSpan">Time span. daily, weekly, all-time</param>
        /// <param name="callback">Callback.</param>
        public void LoadScores(string leaderboardId, LeaderboardStart start,
            int rowCount, LeaderboardCollection collection,
            LeaderboardTimeSpan timeSpan,
            Action<LeaderboardScoreData> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("LoadScores can only be called after authentication.");
                callback(new LeaderboardScoreData(leaderboardId,
                    ResponseStatus.NotAuthorized));
                return;
            }

            mClient.LoadScores(leaderboardId, start,
                rowCount, collection, timeSpan, callback);
        }
Exemple #20
0
            public void ResolveConflict(ISavedGameMetadata chosenMetadata, SavedGameMetadataUpdate metadataUpdate,
                                        byte[] updatedData)
            {
                var convertedMetadata = chosenMetadata as AndroidSnapshotMetadata;

                if (convertedMetadata != mOriginal && convertedMetadata != mUnmerged)
                {
                    Logger.e("Caller attempted to choose a version of the metadata that was not part " +
                             "of the conflict");
                    mCompleteCallback(SavedGameRequestStatus.BadInputError, null);
                    return;
                }

                using (var contentUpdate = mConflict.Call <AndroidJavaObject>("getResolutionSnapshotContents"))
                {
                    if (!contentUpdate.Call <bool>("writeBytes", updatedData))
                    {
                        Logger.e("Can't update snapshot contents during conflict resolution.");
                        mCompleteCallback(SavedGameRequestStatus.BadInputError, null);
                    }

                    using (var convertedMetadataChange = AsMetadataChange(metadataUpdate))
                        using (var task = mSnapshotsClient.Call <AndroidJavaObject>(
                                   "resolveConflict",
                                   mConflict.Call <string>("getConflictId"),
                                   convertedMetadata.JavaMetadata.Call <string>("getSnapshotId"),
                                   convertedMetadataChange,
                                   contentUpdate))
                        {
                            AndroidTaskUtils.AddOnSuccessListener <AndroidJavaObject>(
                                task,
                                dataOrConflict => mRetryFileOpen());

                            mAndroidSavedGameClient.AddOnFailureListenerWithSignOut(
                                task,
                                exception =>
                            {
                                Logger.d("ResolveConflict failed: " + exception.Call <string>("toString"));
                                var status = mAndroidSavedGameClient.mAndroidClient.IsAuthenticated()
                                    ? SavedGameRequestStatus.InternalError
                                    : SavedGameRequestStatus.AuthenticationError;
                                mCompleteCallback(status, null);
                            }
                                );
                        }
                }
            }
        /// <summary>
        /// Reports a score to a leaderboard.
        /// </summary>
        /// <param name='score'>
        /// The score to report.
        /// </param>
        /// <param name='board'>
        /// The ID of the leaderboard on which the score is to be posted. This may be a raw
        /// Google Play Games leaderboard ID or an alias configured through a call to
        /// <see cref="AddIdMapping" />.
        /// </param>
        /// <param name='callback'>
        /// The callback to call to report the success or failure of the operation. The callback
        /// will be called with <c>true</c> to indicate success or <c>false</c> for failure.
        /// </param>
        public void ReportScore(long score, string board, Action<bool> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("ReportScore can only be called after authentication.");
                if (callback != null)
                {
                    callback.Invoke(false);
                }

                return;
            }

            Logger.d("ReportScore: score=" + score + ", board=" + board);
            string lbId = MapId(board);
            mClient.SubmitScore(lbId, score, callback);
        }
Exemple #22
0
        public static void Create(Action <INearbyConnectionClient> callback)
        {
            if (Application.isEditor)
            {
                Logger.d("Creating INearbyConnection in editor, using DummyClient.");
                callback.Invoke(new GooglePlayGames.BasicApi.Nearby.DummyNearbyConnectionClient());
            }
#if (UNITY_ANDROID)
            Logger.d("Creating real INearbyConnectionClient");
            GooglePlayGames.Native.NativeNearbyConnectionClientFactory.Create(callback);
#elif (UNITY_IPHONE && !NO_GPGS)
            Logger.e("Nearby connections not supported in iOS... Using Dummy client");
            callback.Invoke(new GooglePlayGames.BasicApi.Nearby.DummyNearbyConnectionClient());
#else
            Logger.e("Cannot create IPlayGamesClient for unknown platform, returning DummyClient");
            return(new GooglePlayGames.BasicApi.DummyClient());
#endif
        }
        /// <summary>
        /// Set an achievement to have at least the given number of steps completed.
        /// Calling this method while the achievement already has more steps than
        /// the provided value is a no-op. Once the achievement reaches the
        /// maximum number of steps, the achievement is automatically unlocked,
        /// and any further mutation operations are ignored.
        /// </summary>
        /// <param name='achievementID'>
        /// The ID of the achievement to increment. This can be a raw Google Play
        /// Games achievement ID (alphanumeric string), or an alias that was previously configured
        /// by a call to <see cref="AddIdMapping" />.
        /// </param>
        /// <param name='steps'>
        /// The number of steps to increment the achievement by.
        /// </param>
        /// <param name='callback'>
        /// The callback to call to report the success or failure of the operation. The callback
        /// will be called with <c>true</c> to indicate success or <c>false</c> for failure.
        /// </param>
        public void SetStepsAtLeast(string achievementID, int steps, Action<bool> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("SetStepsAtLeast can only be called after authentication.");
                if (callback != null)
                {
                    callback.Invoke(false);
                }

                return;
            }

            // map ID, if it's in the dictionary
            Logger.d("SetStepsAtLeast: " + achievementID + ", steps " + steps);
            achievementID = MapId(achievementID);
            mClient.SetStepsAtLeast(achievementID, steps, callback);
        }
Exemple #24
0
        public void ShowSelectSavedGameUI(string uiTitle, uint maxDisplayedSavedGames, bool showCreateSaveUI,
                                          bool showDeleteSaveUI, Action <SelectUIStatus, ISavedGameMetadata> callback)
        {
            Misc.CheckNotNull(uiTitle);
            Misc.CheckNotNull(callback);

            callback = ToOnGameThread(callback);

            if (!(maxDisplayedSavedGames > 0))
            {
                Logger.e("maxDisplayedSavedGames must be greater than 0");
                callback(SelectUIStatus.BadInputError, null);
                return;
            }

            AndroidHelperFragment.ShowSelectSnapshotUI(
                showCreateSaveUI, showDeleteSaveUI, (int)maxDisplayedSavedGames, uiTitle, callback);
        }
Exemple #25
0
        private void UpdateAchievement(string updateType, string achId, Action <bool> callback,
                                       Predicate <Achievement> alreadyDone, Action <Achievement> updateAchievment)
        {
            callback = AsOnGameThreadCallback(callback);

            Misc.CheckNotNull(achId);

            InitializeGameServices();

            var achievement = GetAchievement(achId);

            if (achievement == null)
            {
                Logger.d("Could not " + updateType + ", no achievement with ID " + achId);
                callback(false);
                return;
            }

            if (alreadyDone(achievement))
            {
                Logger.d("Did not need to perform " + updateType + ": " + "on achievement " + achId);
                callback(true);
                return;
            }

            Logger.d("Performing " + updateType + " on " + achId);
            updateAchievment(achievement);

            GameServices().AchievementManager().Fetch(achId, rsp =>
            {
                if (rsp.Status() == Status.ResponseStatus.VALID)
                {
                    mAchievements.Remove(achId);
                    mAchievements.Add(achId, rsp.Achievement().AsAchievement());
                    callback(true);
                }
                else
                {
                    Logger.e("Cannot refresh achievement " + achId + ": " +
                             rsp.Status());
                    callback(false);
                }
            });
        }
Exemple #26
0
        private void PopulateAchievements(uint authGeneration,
                                          AchievementManager.FetchAllResponse response)
        {
            if (authGeneration != mAuthGeneration)
            {
                Logger.d("Received achievement callback after signout occurred, ignoring");
                return;
            }

            Logger.d("Populating Achievements, status = " + response.Status());
            lock (AuthStateLock)
            {
                if (response.Status() != Status.ResponseStatus.VALID &&
                    response.Status() != Status.ResponseStatus.VALID_BUT_STALE)
                {
                    Logger.e("Error retrieving achievements - check the log for more information. " +
                             "Failing signin.");
                    var localLoudAuthCallbacks = mPendingAuthCallbacks;
                    mPendingAuthCallbacks = null;

                    if (localLoudAuthCallbacks != null)
                    {
                        InvokeCallbackOnGameThread(localLoudAuthCallbacks, false);
                    }
                    SignOut();
                    return;
                }

                var achievements = new Dictionary <string, Achievement>();
                foreach (var achievement in response)
                {
                    using (achievement)
                    {
                        achievements[achievement.Id()] = achievement.AsAchievement();
                    }
                }
                Logger.d("Found " + achievements.Count + " Achievements");
                mAchievements = achievements;
            }

            Logger.d("Maybe finish for Achievements");
            MaybeFinishAuthentication();
        }
        // prepares to create a room
        private bool PrepareToCreateRoom(string method, RealTimeMultiplayerListener listener)
        {
            if (mRtmpActive)
            {
                Logger.e("Cannot call " + method + " while a real-time game is active.");
                if (listener != null)
                {
                    Logger.d("Notifying listener of failure to create room.");
                    listener.OnRoomConnected(false);
                }
                return(false);
            }

            mAccumulatedProgress  = 0.0f;
            mLastReportedProgress = 0.0f;
            mRtmpListener         = listener;
            mRtmpActive           = true;
            return(true);
        }
        /// <summary>
        /// Loads the achievement state for the current user.
        /// <param name="callback">The callback to receive the achievements</param>
        /// </summary>
        public void LoadAchievements(Action<IAchievement[]> callback)
        {
            if (!IsAuthenticated())
            {
                Logger.e("LoadAchievements can only be called after authentication.");
                callback.Invoke(null);
            }

            mClient.LoadAchievements(ach =>
                {
                    IAchievement[] data = new IAchievement[ach.Length];
                    for (int i = 0; i < data.Length; i++)
                    {
                        data[i] = new PlayGamesAchievement(ach[i]);
                    }

                    callback.Invoke(data);
                });
        }
Exemple #29
0
        public void OpenWithManualConflictResolution(string filename, DataSource source, bool prefetchDataOnConflict,
                                                     ConflictCallback conflictCallback, Action <SavedGameRequestStatus, ISavedGameMetadata> completedCallback)
        {
            Misc.CheckNotNull(filename);
            Misc.CheckNotNull(conflictCallback);
            Misc.CheckNotNull(completedCallback);

            conflictCallback  = ToOnGameThread(conflictCallback);
            completedCallback = ToOnGameThread(completedCallback);

            if (!IsValidFilename(filename))
            {
                Logger.e("Received invalid filename: " + filename);
                completedCallback(SavedGameRequestStatus.BadInputError, null);
                return;
            }

            InternalOpen(filename, source, ConflictResolutionStrategy.UseManual, prefetchDataOnConflict,
                         conflictCallback, completedCallback);
        }
        // called from game thread
        public Participant GetSelf()
        {
            Logger.d("AndroidRtmpClient.GetSelf");

            if (!CheckConnectedRoom("GetSelf"))
            {
                return(null);
            }

            Participant self;

            lock (mParticipantListsLock) {
                self = mSelf;
            }

            if (self == null)
            {
                Logger.e("Call to RtmpGetSelf() can only be made when in a room. Returning null.");
            }
            return(self);
        }