SocialSession.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef SOCIALSESSION_H_
  2. #define SOCIALSESSION_H_
  3. #include "SocialSessionListener.h"
  4. #include "SocialPlayer.h"
  5. #include "SocialAchievement.h"
  6. #include "SocialScore.h"
  7. #include "SocialChallenge.h"
  8. #include "Properties.h"
  9. namespace gameplay
  10. {
  11. /**
  12. * Defines an abstract class for typical social game activities running with an authenticated session.
  13. *
  14. * @script{ignore}
  15. */
  16. class SocialSession
  17. {
  18. friend class SocialController;
  19. public:
  20. enum CommunityScope
  21. {
  22. COMMUNITY_SCOPE_FRIENDS,
  23. COMMUNITY_SCOPE_ALL
  24. };
  25. enum TimeScope
  26. {
  27. TIME_SCOPE_TODAY,
  28. TIME_SCOPE_WEEK,
  29. TIME_SCOPE_ALL,
  30. };
  31. /**
  32. * Gets the asynchronous response listener that registered for this session.
  33. *
  34. * @return The asynchronous response listener that registered for this session.
  35. */
  36. virtual SocialSessionListener* getListener() = 0;
  37. virtual const SocialPlayer& getUser() const = 0;
  38. virtual void loadFriends() = 0;
  39. virtual void loadAchievements() = 0;
  40. virtual void submitAchievement(const char* achievementId, unsigned int value, bool achieved=false) = 0;
  41. virtual void incrementAchievement(const char* achievementId, unsigned int increment=1) = 0;
  42. virtual void synchronizeAchievements() = 0;
  43. /**
  44. * Asynchronously request the scores for the count where the player is in the middle.
  45. *
  46. * @param leaderboardId The leaderboard to get populated with the scores.
  47. * @param community The community scope to filter the search list.
  48. * @param time The time scope to filter teh search list.
  49. * @param player The player to narrow the search around.
  50. * @param count The number to scores return in the result.
  51. */
  52. virtual void loadScores(const char* leaderboardId, CommunityScope community, TimeScope time, const SocialPlayer& player, unsigned int count) = 0;
  53. /**
  54. * Asynchronously request the scores for a specified leaderboard for this game.
  55. *
  56. * @param leaderboardId The leaderboard to get populated with the scores.
  57. */
  58. virtual void loadScores(const char* leaderboardId, CommunityScope community, TimeScope time, unsigned int start, unsigned int count) = 0;
  59. virtual void submitScore(const char* leaderboardId, float value) = 0;
  60. virtual void submitChallenge(const SocialPlayer *player, unsigned int wager, float score, const char* leaderboardId=0) = 0;
  61. virtual void loadChallenges(bool showOpenChallengesOnly=true) = 0;
  62. virtual void replyToChallenge(const SocialChallenge *challenge, bool accept) = 0;
  63. virtual void loadSavedData(const char* key) = 0;
  64. virtual void submitSavedData(const char* key, std::string data) = 0;
  65. virtual void displayLeaderboard(const char* leaderboardId) = 0;
  66. virtual void displayAchievements() = 0;
  67. virtual void displayChallenges() = 0;
  68. virtual void displayChallengeSubmit(const SocialChallenge *challenge, float score) = 0;
  69. virtual bool handleEvent(void *event) { return true; }
  70. protected:
  71. /**
  72. * Contructor
  73. */
  74. SocialSession() { }
  75. /**
  76. * Destructor
  77. */
  78. virtual ~SocialSession() { }
  79. };
  80. }
  81. #endif