Exemplo n.º 1
0
        /// <summary>
        /// Post a new transaction of the given currency for the current logged in gamer.
        /// </summary>
        /// <param name="transaction">Transaction currencies data under the Bundle format.</param>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="transactionDescription">Description of the transaction. (optional)</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_Post(Bundle transaction, Action <TransactionResult> OnSuccess = null, Action <ExceptionError> OnError = null, string transactionDescription = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a TransactionResult result
            LoginFeatures.gamer.Transactions.Domain(domain).Post(transaction, transactionDescription)
            // Result if everything went well
            .Done(delegate(TransactionResult postedTransaction)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:TransactionFeatures] Post success ›› New Balance: {0}, Triggered Achievements Count: {1}", postedTransaction.Balance, postedTransaction.TriggeredAchievements.Count));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(postedTransaction);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("TransactionFeatures", "Post", exception);
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the current logged in gamer currencies balance.
        /// </summary>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_Balance(Action <Bundle> OnSuccess = null, Action <ExceptionError> OnError = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a Bundle result
            LoginFeatures.gamer.Transactions.Domain(domain).Balance()
            // Result if everything went well
            .Done(delegate(Bundle currentBalance)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:TransactionFeatures] Balance success ›› Current Balance: {0}", currentBalance));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(currentBalance);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("TransactionFeatures", "Balance", exception);
                }
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the current logged in gamer's history of the given currency (or all currencies if null or empty).
        /// </summary>
        /// <param name="currencyName">Name of the currency to get.</param>
        /// <param name="transactionsPerPage">Number of transactions to get per page.</param>
        /// <param name="transactionsOffset">Number of transactions to skip.</param>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_History(string currencyName, int transactionsPerPage, int transactionsOffset, Action <PagedList <Transaction> > OnSuccess = null, Action <ExceptionError> OnError = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a PagedList<Transaction> result
            LoginFeatures.gamer.Transactions.Domain(domain).History(currencyName, transactionsPerPage, transactionsOffset)
            // Result if everything went well
            .Done(delegate(PagedList <Transaction> transactionsList)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:TransactionFeatures] History success ›› {0} transaction(s)", transactionsList.Count));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(transactionsList);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("TransactionFeatures", "History", exception);
                }
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get the current logged in gamer's best scores from all leaderboards in which he scored at least once.
        /// </summary>
        /// <param name="noScoreErrorMessage">Error message to display in case of no score to display.</param>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_ListUserBestScores(string noScoreErrorMessage, Action <Dictionary <string, Score>, string> OnSuccess = null, Action <ExceptionError, string> OnError = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType), noScoreErrorMessage);
                return;
            }

            // Call the API method which returns a Dictionary<string, Score> result
            LoginFeatures.gamer.Scores.Domain(domain).ListUserBestScores()
            // Result if everything went well
            .Done(delegate(Dictionary <string, Score> scoresList)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:LeaderboardFeatures] ListUserBestScores success ›› {0} score(s)", scoresList.Count));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(scoresList, noScoreErrorMessage);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception), noScoreErrorMessage);
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("LeaderboardFeatures", "ListUserBestScores", exception);
                }
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Post a new score on the given leaderboard for the current logged in gamer.
        /// </summary>
        /// <param name="scoreValue">Value of the score to set.</param>
        /// <param name="boardName">Name of the board to wich to set the score.</param>
        /// <param name="scoreOrder">Determines if the higher or the lower scores are the best ones.</param>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="scoreDescription">Description of the score to set. (optional)</param>
        /// <param name="forceSave">If the score has to be saved even if it's not a better one. (optional)</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_Post(long scoreValue, string boardName, ScoreOrder scoreOrder, Action <PostedGameScore> OnSuccess = null, Action <ExceptionError> OnError = null, string scoreDescription = null, bool forceSave = false, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a PostedGameScore result
            LoginFeatures.gamer.Scores.Domain(domain).Post(scoreValue, boardName, scoreOrder, scoreDescription, forceSave)
            // Result if everything went well
            .Done(delegate(PostedGameScore postedScore)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:LeaderboardFeatures] Post success ›› Has Been Saved: {0}, Score Rank: {1}", postedScore.HasBeenSaved, postedScore.Rank));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(postedScore);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("LeaderboardFeatures", "Post", exception);
                }
            });
        }
Exemplo n.º 6
0
        /// <summary>
        /// Change a logged in gamer's email account's password.
        /// </summary>
        /// <param name="newPassword">New password of the gamer's email account.</param>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        public static void Backend_ChangePassword(string newPassword, Action <Done> OnSuccess = null, Action <ExceptionError> OnError = null)
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a Done result
            LoginFeatures.gamer.Account.ChangePassword(newPassword)
            // Result if everything went well
            .Done(delegate(Done changeDone)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:AccountFeatures] ChangePassword success ›› Successful: {0}", changeDone.Successful));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(changeDone);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("AccountFeatures", "ChangePassword", exception);
                }
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get logged in gamer's progress on all game's achievements.
        /// </summary>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_ListAchievements(Action <Dictionary <string, AchievementDefinition> > OnSuccess = null, Action <ExceptionError> OnError = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a Dictionary<string, AchievementDefinition> result
            LoginFeatures.gamer.Achievements.Domain(domain).List()
            // Result if everything went well
            .Done(delegate(Dictionary <string, AchievementDefinition> achievementsList)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:AchievementFeatures] List success ›› {0} achievement(s)", achievementsList.Count));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(achievementsList);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("AchievementFeatures", "List", exception);
                }
            });
        }
        /// <summary>
        /// Delete the given key (or all keys if null or empty) associated to the current logged in gamer.
        /// </summary>
        /// <param name="key">Name of the key to delete.</param>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_DeleteValue(string key, Action <Done> OnSuccess = null, Action <ExceptionError> OnError = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a Done result
            LoginFeatures.gamer.GamerVfs.Domain(domain).DeleteValue(key)
            // Result if everything went well
            .Done(delegate(Done deleteDone)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:GamerVFSFeatures] DeleteValue success ›› Successful: {0}", deleteDone.Successful));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(deleteDone);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("GamerVFSFeatures", "DeleteValue", exception);
                }
            });
        }
        /// <summary>
        /// Get the logged in gamer's referral code.
        /// </summary>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_GenerateCode(Action <string> OnSuccess = null, Action <ExceptionError> OnError = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a string result
            LoginFeatures.gamer.Godfather.Domain(domain).GenerateCode()
            // Result if everything went well
            .Done(delegate(string referralCode)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:GodfatherFeatures] GenerateCode success ›› Referral Code: {0}", referralCode));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(referralCode);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("GodfatherFeatures", "GenerateCode", exception);
                }
            });
        }
Exemplo n.º 10
0
        /// <summary>
        /// Set the relationship between the current logged in gamer and the given other gamer.
        /// </summary>
        /// <param name="gamerID">Identifier of the gamer with who to change the relationship.</param>
        /// <param name="relationship">Type of relationship to set.</param>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="pushNotification">Message to send as notification if the target gamer is offline. (optional)</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_ChangeRelationshipStatus(string gamerID, FriendRelationshipStatus relationship, Action <Done, string, FriendRelationshipStatus> OnSuccess = null, Action <ExceptionError, string, FriendRelationshipStatus> OnError = null, PushNotification pushNotification = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType), gamerID, relationship);
                return;
            }

            // Call the API method which returns a Done result
            LoginFeatures.gamer.Community.Domain(domain).ChangeRelationshipStatus(gamerID, relationship, pushNotification)
            // Result if everything went well
            .Done(delegate(Done changeDone)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:CommunityFeatures] ChangeRelationshipStatus success ›› Successful: {0}", changeDone.Successful));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(changeDone, gamerID, relationship);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception), gamerID, relationship);
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("CommunityFeatures", "ChangeRelationshipStatus", exception);
                }
            });
        }
Exemplo n.º 11
0
        /// <summary>
        /// Get the list of current logged in gamer's friends (or blacklisted gamers).
        /// </summary>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="blacklisted">Get blacklisted gamers instead of friends. (optional)</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_ListFriends(Action <NonpagedList <GamerInfo> > OnSuccess = null, Action <ExceptionError> OnError = null, bool blacklisted = false, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a NonpagedList<GamerInfo> result
            LoginFeatures.gamer.Community.Domain(domain).ListFriends(blacklisted)
            // Result if everything went well
            .Done(delegate(NonpagedList <GamerInfo> friendsList)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:CommunityFeatures] ListFriends success ›› {0} friend(s) (or blacklisted)", friendsList.Count));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(friendsList);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("CommunityFeatures", "ListFriends", exception);
                }
            });
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get the list of current logged in gamer's godchildren.
        /// </summary>
        /// <param name="OnSuccess">The callback in case of request success.</param>
        /// <param name="OnError">The callback in case of request error.</param>
        /// <param name="domain">We use the "private" domain by default (each game holds its own data, not shared with the other games). You may configure shared domains on your FrontOffice.</param>
        public static void Backend_GetGodchildren(Action <NonpagedList <GamerInfo> > OnSuccess = null, Action <ExceptionError> OnError = null, string domain = "private")
        {
            // Need an initialized Cloud and a logged in gamer to proceed
            if (!LoginFeatures.IsGamerLoggedIn())
            {
                OnError(ExceptionTools.GetExceptionError(new CotcException(CotcSdk.ErrorCode.NotLoggedIn), ExceptionTools.notLoggedInErrorType));
                return;
            }

            // Call the API method which returns a NonpagedList<GamerInfo> result
            LoginFeatures.gamer.Godfather.Domain(domain).GetGodchildren()
            // Result if everything went well
            .Done(delegate(NonpagedList <GamerInfo> godchildrenList)
            {
                DebugLogs.LogVerbose(string.Format("[CotcSdkTemplate:GodfatherFeatures] GetGodchildren success ›› {0} godchild(ren)", godchildrenList.Count));

                // Call the OnSuccess action if any callback registered to it
                if (OnSuccess != null)
                {
                    OnSuccess(godchildrenList);
                }
            },
                  // Result if an error occured
                  delegate(Exception exception)
            {
                // Call the OnError action if any callback registered to it
                if (OnError != null)
                {
                    OnError(ExceptionTools.GetExceptionError(exception));
                }
                // Else, log the error (expected to be a CotcException)
                else
                {
                    ExceptionTools.LogCotcException("GodfatherFeatures", "GetGodchildren", exception);
                }
            });
        }