* Added LB2017 apis

* Added codeflow feedback

* fixed build breaks

* Modified more from codeflow changes

* changed continuation token to a has_next

* Fixed the docs on the APIs
This commit is contained in:
Garrett Woodford 2017-02-27 18:56:05 -08:00 коммит произвёл GitHub
Родитель 031bd47e20
Коммит 695b48d9c0
36 изменённых файлов: 1096 добавлений и 106 удалений

Просмотреть файл

@ -211,6 +211,8 @@
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship_result.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_user_profile.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_service.cpp" />

Просмотреть файл

@ -711,6 +711,12 @@
<ClCompile Include="..\..\Source\Shared\call_buffer_timer.cpp">
<Filter>Shared</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\stat_event.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>

Просмотреть файл

@ -342,12 +342,16 @@
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship_result.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_user_profile.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_service.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_value_document.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stat_event.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stat_value.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardQuery_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardResultEventArgs_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEvent_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticManager_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticValue_WinRT.cpp" />
@ -654,8 +658,12 @@
<ClInclude Include="..\..\Source\Services\Common\WinRT\pch.h" />
<ClInclude Include="..\..\Source\Services\Common\WinRT\XboxLiveContext_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\stats_manager_internal.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardQuery_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardResultEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\SortOrder_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticDataType_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEventType_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEvent_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticManager_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticValue_WinRT.h" />

Просмотреть файл

@ -1236,6 +1236,18 @@
<ClCompile Include="..\..\Source\Shared\WinRT\XboxLiveServicesSettings_WinRT.cpp">
<Filter>Shared\WinRT Source</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\LeaderboardResultEventArgs_WinRT.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\LeaderboardQuery_WinRT.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\stat_event.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
@ -2144,6 +2156,18 @@
<ClInclude Include="..\..\Source\Services\Stats\Manager\stats_manager_internal.h">
<Filter>C++ Source\Stats</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardResultEventArgs_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEventArgs_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\SortOrder_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardQuery_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticDataType_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>

Просмотреть файл

@ -293,6 +293,8 @@
<ClCompile Include="..\..\Source\Services\Social\social_relationship_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Social\social_relationship_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Social\social_service_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_service.cpp" />

Просмотреть файл

@ -720,6 +720,12 @@
<ClCompile Include="..\..\Source\Shared\call_buffer_timer.cpp">
<Filter>C++ Source\Shared</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\http_call_response.h">

Просмотреть файл

@ -115,7 +115,7 @@
<AdditionalDependencies>windowsapp.lib;msxml6.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<DelayLoadDLLs>
<DelayLoadDLLs>
api-ms-win-gaming-tcui-l1-1-2.dll;
%(DelayLoadDLLs)
</DelayLoadDLLs>
@ -408,12 +408,16 @@
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship_result.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_user_profile.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_service.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_value_document.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stat_event.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stat_value.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardQuery_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardResultEventArgs_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEvent_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticManager_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticValue_WinRT.cpp" />
@ -713,7 +717,11 @@
<ClInclude Include="..\..\Source\Services\Common\WinRT\pch.h" />
<ClInclude Include="..\..\Source\Services\Common\WinRT\XboxLiveContext_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\stats_manager_internal.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardQuery_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardResultEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\SortOrder_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticDataType_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEventType_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEvent_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticManager_WinRT.h" />

Просмотреть файл

@ -1230,6 +1230,18 @@
<ClCompile Include="..\..\Source\Services\Misc\UWP\title_callable_ui.cpp">
<Filter>C++ Source\Misc</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardQuery_WinRT.cpp">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardResultEventArgs_WinRT.cpp">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Source\Shared\WinRT\Macros_WinRT.h">
@ -2030,12 +2042,6 @@
<ClInclude Include="..\..\Source\Services\Social\Manager\WinRT\SocialUserGroupLoadedEventArgs_WinRT.h">
<Filter>C++ Source\Social\Manager\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Shared\WinRT\SignInUIGameCategory_WinRT.h">
<Filter>C++ Source\Shared\WinRT Source</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Shared\WinRT\SignInUIEmphasisFeature_WinRT.h">
<Filter>C++ Source\Shared\WinRT Source</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Shared\Logger\debug_output.h">
<Filter>C++ Source\Shared\Logger</Filter>
</ClInclude>
@ -2120,5 +2126,17 @@
<ClInclude Include="..\..\Source\Services\Misc\WinRT\TitleCallableUI_WinRT.h">
<Filter>C++ Source\Misc\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardQuery_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\SortOrder_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\LeaderboardResultEventArgs_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Stats\Manager\WinRT\StatisticEventArgs_WinRT.h">
<Filter>C++ Source\Stats\WinRT</Filter>
</ClInclude>
</ItemGroup>
</Project>

Просмотреть файл

@ -211,6 +211,8 @@
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_social_relationship_result.cpp" />
<ClCompile Include="..\..\Source\Services\Social\xbox_user_profile.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_manager_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Stats\Manager\stats_service.cpp" />

Просмотреть файл

@ -711,6 +711,12 @@
<ClCompile Include="..\..\Source\Services\Social\Manager\xbox_user_id_container.cpp">
<Filter>C++ Source\Social\Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_query.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\leaderboard_result_event_args.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Stats\Manager\stat_event.cpp">
<Filter>C++ Source\Stats</Filter>
</ClCompile>

Просмотреть файл

@ -19,6 +19,11 @@
namespace xbox { namespace services {
class xbox_live_context_impl;
namespace stats {
namespace manager {
class stats_manager_impl;
}
}
/// <summary>
/// Contains classes and enumerations that let you retrieve
/// leaderboard information from Xbox Live.
@ -54,6 +59,22 @@ enum class leaderboard_stat_type
stat_other
};
/// <summary>
/// The order to sort the leaderboard in
/// </summary>
enum class sort_order
{
/// <summary>
/// Sorting the Leaderboard lowest to highest
/// </summary>
ascending,
/// <summary>
/// Sorting the Leaderboard highest to lowest
/// </summary>
descending
};
/// <summary>
/// Represents a column in a collection of leaderboard items.
/// </summary>
@ -140,6 +161,104 @@ private:
friend leaderboard_result;
};
class leaderboard_query
{
public:
/// <summary>
/// Contructing a leaderboard_query object
/// </summary>
leaderboard_query();
/// <summary>
/// Set whether or not the resulting leaderboard will start with the
/// user that requested the leaderboard.
/// </summary>
void set_skip_result_to_me(_In_ bool skipResultToMe);
/// <summary>
/// Set Which rank the resulting leaderboard will start at
/// </summary>
void set_skip_result_to_rank(_In_ uint32_t skipResultToRank);
/// <summary>
/// Set maximum items that the resulting leaderboard will contain
/// </summary>
void set_max_items(_In_ uint32_t maxItems);
/// <summary>
/// Set sort order for the resulting leaderboard
/// </summary>
void set_order(_In_ sort_order order);
/// <summary>
/// Gets whether or not the resulting leaderboard will start with the
/// user that requested the leaderboard.
/// </summary>
bool skip_result_to_me() const;
/// <summary>
/// Gets Which rank the resulting leaderboard will start at
/// </summary>
uint32_t skip_result_to_rank() const;
/// <summary>
/// Gets maximum items that the resulting leaderboard will contain
/// </summary>
uint32_t max_items() const;
/// <summary>
/// Gets sort order for the resulting leaderboard
/// </summary>
sort_order order() const;
/// <summary>
/// Gets the stat name of the previous query. This property will only be set if its a query
/// gotten from get_next_query
/// </summary>
const string_t& stat_name() const;
/// <summary>
/// Gets the social group of the previous query. This property will only be set if its a query
/// gotten from get_next_query and the previous query was a social query
/// </summary>
const string_t& social_group() const;
/// <summary>
/// True if there is more data in the leaderboard
/// If this is true then you can pass this object into the get_leaderboard call
/// </summary>
bool has_next() const;
/// <summary>
/// Internal Function
/// </summary>
const string_t& _Continuation_token() const;
/// <summary>
/// Internal Function
/// </summary>
void _Set_continuation_token(_In_ const string_t& continuationToken);
/// <summary>
/// Internal Function
/// </summary>
void _Set_stat_name(_In_ const string_t& statName);
/// <summary>
/// Internal Function
/// </summary>
void _Set_social_group(_In_ const string_t& socialGroup);
private:
bool m_skipResultToMe;
uint32_t m_skipResultToRank;
uint32_t m_maxItems;
sort_order m_order;
string_t m_continuationToken;
string_t m_statName;
string_t m_socialGroup;
};
/// <summary>
/// Represents the results of a leaderboard request.
/// </summary>
@ -192,12 +311,14 @@ public:
/// <returns>True if there is another page of results; otherwise false.</returns>
_XSAPIIMP bool has_next() const;
#if !defined(XBOX_LIVE_CREATORS_SDK)
/// <summary>
/// Get the next page of a previous leaderboard call using the same service config Id and leaderboard name.
/// </summary>
/// <param name="maxItems">The maximum number of items to return.</param>
/// <returns>A leaderboard_results object that contains the next set of results.</returns>
/// <remarks>
/// This query is only to be used to retrieve a leaderboard in a pre stats 2017 system
/// Returns a concurrency::task&lt;T&gt; object that represents the state of the asynchronous operation.
///
/// Calls V1 GET /scids/{scid}/leaderboards/{leaderboardname}?
@ -205,6 +326,13 @@ public:
/// [continuationToken={token}]
/// </remarks>
_XSAPIIMP pplx::task<xbox_live_result<leaderboard_result>> get_next(_In_ uint32_t maxItems) const;
#endif
/// <summary>
/// Gets a query to be used to retrieve more data about a leaderboard.
/// This query is only to be used to retrieve a leaderboard with stats 2017.
/// </summary>
_XSAPIIMP xbox_live_result<leaderboard_query> get_next_query() const;
/// <summary>
/// Internal function
@ -216,6 +344,11 @@ public:
/// </summary>
void _Set_next_query(std::shared_ptr<leaderboard_social_query> query);
/// <summary>
/// Internal function
/// </summary>
void _Set_next_query(const leaderboard_query& query);
/// <summary>
/// Internal function
/// </summary>
@ -234,8 +367,11 @@ private:
std::shared_ptr<leaderboard_global_query> m_globalQuery;
std::shared_ptr<leaderboard_social_query> m_socialQuery;
leaderboard_query m_nextQuery;
string_t m_version;
};
#if !defined(XBOX_LIVE_CREATORS_SDK)
/// <summary>
/// Represents the leaderboard service.
/// </summary>
@ -548,7 +684,9 @@ private:
_In_ const string_t& skipToXuid,
_In_ const string_t& sortOrder,
_In_ uint32_t maxItems,
_In_ const string_t& continuationToken
_In_ const string_t& continuationToken,
_In_ const string_t& version = string_t(),
_In_ leaderboard_query lbQuery = leaderboard_query()
);
pplx::task<xbox_live_result<leaderboard_result>> get_leaderboard_internal(
@ -560,7 +698,9 @@ private:
_In_ const string_t& socialGroup,
_In_ uint32_t maxItems,
_In_ const string_t& continuationToken,
_In_ const std::vector<string_t>& additionalColumnNames = std::vector<string_t>()
_In_ const std::vector<string_t>& additionalColumnNames = std::vector<string_t>(),
_In_ const string_t& version = string_t(),
_In_ leaderboard_query lbQuery = leaderboard_query()
);
pplx::task<xbox_live_result<leaderboard_result>> get_leaderboard_for_url(
@ -572,7 +712,8 @@ private:
std::shared_ptr<xbox::services::xbox_live_app_config> m_appConfig;
friend leaderboard_result;
friend stats::manager::stats_manager_impl;
friend xbox_live_context_impl;
};
#endif
}}}

Просмотреть файл

@ -13,6 +13,7 @@
#include "xsapi/service_call_logging_config.h"
#if !BEAM_API
#include "xsapi/leaderboard.h"
#include "xsapi/social_manager.h"
#include "xsapi/stats_manager.h"
@ -20,7 +21,6 @@
#include "xsapi/http_call.h"
#include "xsapi/xbox_live_context_settings.h"
#include "xsapi/events.h"
#include "xsapi/leaderboard.h"
#include "xsapi/title_storage.h"
#include "xsapi/privacy.h"
#include "xsapi/profile.h"

Просмотреть файл

@ -43,19 +43,25 @@ enum class stat_data_type
/// </summary>
enum class stat_event_type
{
/// <summary>
/// A local user has been added
/// </summary>
local_user_added,
/// <summary>
/// A local user has been removed
/// </summary>
local_user_removed,
stat_update_complete
};
/// <summary>
/// stat has been updated
/// </summary>
stat_update_complete,
/// <summary>
/// The order to sort the leaderboard in
/// </summary>
enum class sort_order
{
ascending,
descending
/// <summary>
/// cast event args to leaderboard_result_event_args
/// </summary>
get_leaderboard_complete
};
/// <summary>
@ -68,34 +74,34 @@ public:
/// Name of the statistic
/// </summary>
/// <returns>A stat container that has the stat name string</returns>
const string_t name() const;
_XSAPIIMP const string_t name() const;
/// <summary>
/// Return data as numerical type
/// </summary>
/// <returns>Float data for statistic</returns>
/// <remarks>Will debug assert if data is not type requested</returns>
double as_number() const;
_XSAPIIMP double as_number() const;
/// <summary>
/// Return data as integer type
/// </summary>
/// <returns>Float data for statistic</returns>
/// <remarks>Will debug assert if data is not type requested</returns>
int64_t as_integer() const;
_XSAPIIMP int64_t as_integer() const;
/// <summary>
/// Return data as string type
/// </summary>
/// <returns>data as char_t*</returns>
/// <remarks>Will debug assert if data is not type requested</returns>
const string_t as_string() const;
_XSAPIIMP const string_t as_string() const;
/// <summary>
/// Return type of data the data object is
/// </summary>
/// <returns>Stat data type</returns>
stat_data_type data_type() const;
_XSAPIIMP stat_data_type data_type() const;
/// Internal function
static xbox_live_result<stat_value> _Deserialize(_In_ const web::json::value& data);
@ -126,6 +132,28 @@ private:
friend class stats_value_document;
};
struct stat_event_args
{
virtual ~stat_event_args() {}
};
class leaderboard_result_event_args : public stat_event_args
{
public:
/// <summary>
/// Gets the leaderboard result from a leaderboard request
/// </summary>
_XSAPIIMP const xbox_live_result<leaderboard::leaderboard_result>& result();
/// <summary>
/// Internal function
/// </summary>
leaderboard_result_event_args(const xbox_live_result<leaderboard::leaderboard_result>& result);
private:
xbox_live_result<leaderboard::leaderboard_result> m_result;
};
class stat_event
{
public:
@ -133,29 +161,37 @@ public:
/// Represents error code and error message
/// </summary>
/// <return>The returned xbox live result</return>
xbox_live_result<void>& error_info();
_XSAPIIMP xbox_live_result<void>& error_info();
/// <summary>
/// The type of event the statistic is
/// </summary>
/// <return>The event type</return>
stat_event_type event_type() const;
_XSAPIIMP stat_event_type event_type() const;
/// <summary>
/// The data of event from stats manager
/// You need to cast this to one of the event arg classes to retrieve the data for that particular event
/// </summary>
_XSAPIIMP std::shared_ptr<stat_event_args> event_args() const;
/// <summary>
/// Local user the event is for
/// </summary>
/// <return>The returned user</return>
const xbox_live_user_t& local_user() const;
_XSAPIIMP const xbox_live_user_t& local_user() const;
/// Internal function
stat_event(
stat_event_type eventType,
xbox_live_user_t user,
xbox_live_result<void> errorInfo
xbox_live_result<void> errorInfo,
std::shared_ptr<stat_event_args> args = nullptr
);
private:
stat_event_type m_eventType;
std::shared_ptr<stat_event_args> m_eventArgs;
xbox_live_user_t m_localUser;
xbox_live_result<void> m_errorInfo;
};
@ -169,14 +205,14 @@ public:
/// <summary>
/// Instantiates and returns an instance of stats manager
/// </summary>
static std::shared_ptr<stats_manager> get_singleton_instance();
_XSAPIIMP static std::shared_ptr<stats_manager> get_singleton_instance();
/// <summary>
/// Adds a local user to the stats manager
/// Returns a local_user_added event from do_work
/// </summary>
/// <param name="user">The user to add to the statistic manager</param>
xbox_live_result<void> add_local_user(
_XSAPIIMP xbox_live_result<void> add_local_user(
_In_ const xbox_live_user_t& user
);
@ -185,7 +221,7 @@ public:
/// Returns a local_user_removed event from do_work
/// </summary>
/// <param name="user">The user to be removed from the statistic manager</param>
xbox_live_result<void> remove_local_user(
_XSAPIIMP xbox_live_result<void> remove_local_user(
_In_ const xbox_live_user_t& user
);
@ -193,8 +229,8 @@ public:
/// Requests the current stat values to be uploaded to the service
/// This will send immediately instead of automatically during a 30 second window
/// </summary>
/// <remarks>This can be throttled if called too often</remarks>
xbox_live_result<void> request_flush_to_service(
/// <remarks>This will be throttled if called too often</remarks>
_XSAPIIMP xbox_live_result<void> request_flush_to_service(
_In_ const xbox_live_user_t& user,
_In_ bool isHighPriority = false
);
@ -203,52 +239,45 @@ public:
/// Returns any events that have been processed
/// </summary>
/// <return>A list of events that have happened since previous do_work</return>
std::vector<stat_event> do_work();
_XSAPIIMP std::vector<stat_event> do_work();
/// <summary>
/// Replaces the numerical stat by the value. Can be positive or negative
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="name">The name of the statistic to modify</param>
/// <param name="value">Value to replace the stat by</param>
/// <param name="statisticReplaceCompareType">
/// Will override the compare type. Stat will only be updated if follows the stat compares rule
/// </param>
/// <param name="statName">The name of the statistic to modify</param>
/// <param name="statValue">Value to replace the stat by</param>
/// <return>Whether or not the setting was successful. Can fail if stat is not of numerical type. Will return updated stat</return>
xbox_live_result<void> set_stat_as_number(
_XSAPIIMP xbox_live_result<void> set_stat_as_number(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name,
_In_ double value
_In_ const string_t& statName,
_In_ double statValue
);
/// <summary>
/// Replaces the numerical stat by the value. Can be positive or negative
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="name">The name of the statistic to modify</param>
/// <param name="value">Value to replace the stat by</param>
/// <param name="statisticReplaceCompareType">
/// Will override the compare type. Stat will only be updated if follows the stat compares rule
/// *Note* This is not recommended to be modified after release of the title
/// </param>
/// <param name="statName">The name of the statistic to modify</param>
/// <param name="statValue">Value to replace the stat by</param>
/// <return>Whether or not the setting was successful. Can fail if stat is not of numerical type. Will return updated stat</return>
xbox_live_result<void> set_stat_as_integer(
_XSAPIIMP xbox_live_result<void> set_stat_as_integer(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name,
_In_ int64_t value
_In_ const string_t& statName,
_In_ int64_t statValue
);
/// <summary>
/// Replaces a string stat with the given value.
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="name">The name of the statistic to modify</param>
/// <param name="value">Value to replace the stat by</param>
/// <param name="statName">The name of the statistic to modify</param>
/// <param name="statValue">Value to replace the stat by</param>
/// <return>Whether or not the setting was successful. Can fail if stat is not of string type. Will return updated stat</return>
xbox_live_result<void> set_stat_as_string(
_XSAPIIMP xbox_live_result<void> set_stat_as_string(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name,
_In_ const string_t& value
_In_ const string_t& statName,
_In_ const string_t& statValue
);
/// <summary>
@ -257,7 +286,7 @@ public:
/// <param name="user">The local user whose stats to access</param>
/// <param name="statNameList">The list to fill with stat names</param>
/// <return>Whether or not the setting was successful.</return>
xbox_live_result<void> get_stat_names(
_XSAPIIMP xbox_live_result<void> get_stat_names(
_In_ const xbox_live_user_t& user,
_Inout_ std::vector<string_t>& statNameList
);
@ -266,25 +295,57 @@ public:
/// Gets a stat value
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="name">The name of the statistic to modify</param>
/// <param name="statName">The name of the statistic to modify</param>
/// <return>Whether or not the setting was successful along with updated stat</return>
xbox_live_result<stat_value> get_stat(
_XSAPIIMP xbox_live_result<stat_value> get_stat(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name
_In_ const string_t& statName
);
/// <summary>
/// Deletes a stat. Will clear stat from service and social leaderboard information
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="name">The name of the statistic to delete</param>
/// <param name="statName">The name of the statistic to delete</param>
/// <return>Whether or not the stat deletion was successful</return>
xbox_live_result<void> delete_stat(
_XSAPIIMP xbox_live_result<void> delete_stat(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name
_In_ const string_t& statName
);
stats_manager();
_XSAPIIMP stats_manager();
/// <summary>
/// Starts a request for a global leaderboard. You can retrieve the resulting data by checking
/// the events returned from do_work for an event of type get_leaderboard_complete
/// Use leaderboard_query::get_next_query() to retrieve more data about this leaderboard.
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="statName">The name of the statistic to get the leaderboard of</param>
/// <param name="query">The query parameters of the leaderboard request</param>
/// <return>Whether or not the leaderboard request was started correctly</return>
_XSAPIIMP xbox_live_result<void> get_leaderboard(
_In_ const xbox_live_user_t& user,
_In_ const string_t& statName,
_In_ leaderboard::leaderboard_query query
);
/// <summary>
/// Starts a request for a social leaderboard. You can retrieve the resulting data by checking
/// the events returned from do_work for an event of type get_leaderboard_complete
/// Use leaderboard_query::get_next_query() to retrieve more data about this leaderboard.
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="statName">The name of the statistic to get the leaderboard of</param>
/// <param name="socialGroup">The name of the social group</param>
/// <param name="query">The query parameters of the leaderboard request</param>
/// <return>Whether or not the leaderboard request was started correctly</return>
_XSAPIIMP xbox_live_result<void> get_social_leaderboard(
_In_ const xbox_live_user_t& user,
_In_ const string_t& statName,
_In_ const string_t& socialGroup,
_In_ leaderboard::leaderboard_query query
);
private:
std::shared_ptr<stats_manager_impl> m_statsManagerImpl;

Просмотреть файл

@ -58,4 +58,12 @@ LeaderboardResult::GetNextAsync(_In_ uint32 maxItems)
return ASYNC_FROM_TASK(task);
}
LeaderboardQuery^ LeaderboardResult::GetNextQuery()
{
auto result = m_cppObj.get_next_query();
THROW_IF_ERR(result);
return ref new LeaderboardQuery(result.payload());
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_END

Просмотреть файл

@ -7,6 +7,7 @@
#include "Macros_WinRT.h"
#include "LeaderboardColumn.h"
#include "LeaderboardRow.h"
#include "../../Stats/Manager/WinRT/LeaderboardQuery_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_BEGIN
@ -68,6 +69,13 @@ public:
/// </remarks>
Windows::Foundation::IAsyncOperation<LeaderboardResult^>^ GetNextAsync(_In_ uint32 maxItems);
/// <summary>
/// Gets a query to be used to retrieve more data about a leaderboard.
/// This query is only to be used to retrieve a leaderboard with stats 2017.
/// </summary>
LeaderboardQuery^ GetNextQuery();
internal:
LeaderboardResult(
_In_ xbox::services::leaderboard::leaderboard_result cppObj

Просмотреть файл

@ -64,6 +64,12 @@ void leaderboard_result::_Set_next_query(std::shared_ptr<leaderboard_social_quer
m_socialQuery = std::move(query);
}
void leaderboard_result::_Set_next_query(const leaderboard_query& query)
{
m_version = _T("2017");
m_nextQuery = std::move(query);
}
void leaderboard_result::_Parse_additional_columns(const std::vector<string_t>& additionalColumnNames)
{
std::vector<leaderboard_column> columns;
@ -127,6 +133,11 @@ bool leaderboard_result::has_next() const
pplx::task<xbox_live_result<leaderboard_result>> leaderboard_result::get_next(_In_ uint32_t maxItems) const
{
if (m_version == _T("2017"))
{
return pplx::task_from_result(xbox_live_result<leaderboard_result>(xbox_live_error_code::unsupported, "This API is NOT supported for using leaderboards that are configured with stats 2017. Use get_next_query() instead."));
}
if (m_continuationToken.empty())
{
return pplx::task_from_result(xbox_live_result<leaderboard_result>(xbox_live_error_code::out_of_range, "leadboard_result does not have a next page"));
@ -170,4 +181,16 @@ pplx::task<xbox_live_result<leaderboard_result>> leaderboard_result::get_next(_I
return pplx::task_from_result(xbox_live_result<leaderboard_result>(xbox_live_error_code::runtime_error, "no query found to continue"));
}
xbox_live_result<leaderboard_query> leaderboard_result::get_next_query() const
{
if (m_version == _T("2017"))
{
return xbox_live_result<leaderboard_query>(m_nextQuery);
}
else
{
return xbox_live_result<leaderboard_query>(xbox_live_error_code::unsupported, "This API is only supported for using leaderboards that are configured with stats 2017. Use get_next() instead");
}
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_CPP_END

Просмотреть файл

@ -78,7 +78,9 @@ deserialize_result(
_In_ const web::json::value& json,
_In_ std::shared_ptr<xbox::services::user_context> userContext,
_In_ std::shared_ptr<xbox::services::xbox_live_context_settings> xboxLiveContextSettings,
_In_ std::shared_ptr<xbox::services::xbox_live_app_config> appConfig
_In_ std::shared_ptr<xbox::services::xbox_live_app_config> appConfig,
_In_ const string_t& version,
_In_ leaderboard_query query
)
{
std::error_code errc;
@ -113,7 +115,7 @@ deserialize_result(
auto result = leaderboard_result(
string_t(),
totalCount,
std::move(continuationToken),
continuationToken,
std::move(columns),
std::move(rows),
userContext,
@ -121,6 +123,12 @@ deserialize_result(
appConfig
);
if (version == _T("2017"))
{
query._Set_continuation_token(continuationToken);
result._Set_next_query(query);
}
return xbox_live_result<leaderboard_result>(result, errc);
}

Просмотреть файл

@ -18,7 +18,9 @@ xbox_live_result<leaderboard_result> deserialize_result(
_In_ const web::json::value& json,
_In_ std::shared_ptr<xbox::services::user_context> userContext,
_In_ std::shared_ptr<xbox::services::xbox_live_context_settings> xboxLiveContextSettings,
_In_ std::shared_ptr<xbox::services::xbox_live_app_config> appConfig
_In_ std::shared_ptr<xbox::services::xbox_live_app_config> appConfig,
_In_ const string_t& version = string_t(),
_In_ leaderboard_query query = leaderboard_query()
);
}

Просмотреть файл

@ -13,6 +13,7 @@ NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_CPP_BEGIN
const string_t c_leaderboard_social_stat_name_contract_version = _T("1");
const string_t c_leaderboard_with_metadata_contract_version = _T("3");
const string_t c_leaderboard_with_stats_2017_version = _T("4");
leaderboard_service::leaderboard_service(
_In_ std::shared_ptr<xbox::services::user_context> userContext,
@ -243,7 +244,8 @@ xbox_live_result<string_t> create_leaderboard_url(
_In_ const string_t& continuationToken,
_In_ bool metadata,
_In_ const string_t& xuid = string_t(),
_In_ const string_t& socialGroup = string_t()
_In_ const string_t& socialGroup = string_t(),
_In_ const string_t& version = string_t()
)
{
if (scid.empty())
@ -256,9 +258,19 @@ xbox_live_result<string_t> create_leaderboard_url(
stringstream_t path;
path << _T("/scids/");
path << web::uri::encode_uri(scid, web::uri::components::path);
path << _T("/leaderboards/");
path << web::uri::encode_uri(name, web::uri::components::path);
builder.set_path(path.str());
if (version == _T("2017"))
{
path << _T("/leaderboards/stat(");
path << web::uri::encode_uri(name, web::uri::components::path);
path << _T(")");
builder.set_path(path.str());
}
else
{
path << _T("/leaderboards/");
path << web::uri::encode_uri(name, web::uri::components::path);
builder.set_path(path.str());
}
if (metadata)
{
@ -314,7 +326,9 @@ pplx::task<xbox_live_result<leaderboard_result>> leaderboard_service::get_leader
_In_ const string_t& socialGroup,
_In_ uint32_t maxItems,
_In_ const string_t& continuationToken,
_In_ const std::vector<string_t>& additionalColumnNames
_In_ const std::vector<string_t>& additionalColumnNames,
_In_ const string_t& version,
_In_ leaderboard_query lbQuery
)
{
xbox_live_result<string_t> url = create_leaderboard_url(
@ -326,7 +340,8 @@ pplx::task<xbox_live_result<leaderboard_result>> leaderboard_service::get_leader
continuationToken,
additionalColumnNames.size() != 0,
xuid,
socialGroup
socialGroup,
version
);
RETURN_TASK_CPP_IF_ERR(url, leaderboard_result);
@ -345,22 +360,31 @@ pplx::task<xbox_live_result<leaderboard_result>> leaderboard_service::get_leader
url.payload(),
xbox_live_api::get_leaderboard_internal
);
http_call->set_xbox_contract_version_header_value(c_leaderboard_with_metadata_contract_version);
if (version == _T("2017"))
{
http_call->set_xbox_contract_version_header_value(c_leaderboard_with_stats_2017_version);
lbQuery._Set_stat_name(name);
}
else
{
http_call->set_xbox_contract_version_header_value(c_leaderboard_with_metadata_contract_version);
}
auto userContext = m_userContext;
auto xboxLiveContextSettings = m_xboxLiveContextSettings;
auto appConfig = m_appConfig;
auto task = http_call->get_response_with_auth(m_userContext)
.then([userContext, xboxLiveContextSettings, appConfig, additionalColumnNames](std::shared_ptr<http_call_response> response)
.then([userContext, xboxLiveContextSettings, appConfig, additionalColumnNames, version, lbQuery](std::shared_ptr<http_call_response> response)
{
return utils::generate_xbox_live_result<leaderboard_result>(
serializers::deserialize_result(
response->response_body_json(),
userContext,
xboxLiveContextSettings,
appConfig
appConfig,
version,
lbQuery
),
response
);
@ -452,7 +476,9 @@ pplx::task<xbox_live_result<leaderboard_result>> leaderboard_service::get_leader
_In_ const string_t& skipToXuid,
_In_ const string_t& sortOrder,
_In_ uint32_t maxItems,
_In_ const string_t& continuationToken
_In_ const string_t& continuationToken,
_In_ const string_t& version,
_In_ leaderboard_query lbQuery
)
{
// To align with People moniker support, we are mapping "People" to "all" until the
@ -492,15 +518,23 @@ pplx::task<xbox_live_result<leaderboard_result>> leaderboard_service::get_leader
url.payload(),
xbox_live_api::get_leaderboard_for_social_group_internal
);
http_call->set_xbox_contract_version_header_value(c_leaderboard_social_stat_name_contract_version);
if (version == _T("2017"))
{
http_call->set_xbox_contract_version_header_value(c_leaderboard_with_stats_2017_version);
lbQuery._Set_stat_name(statName);
lbQuery._Set_social_group(socialGroup);
}
else
{
http_call->set_xbox_contract_version_header_value(c_leaderboard_social_stat_name_contract_version);
}
auto userContext = m_userContext;
auto xboxLiveContextSettings = m_xboxLiveContextSettings;
auto appConfig = m_appConfig;
auto task = http_call->get_response_with_auth(m_userContext)
.then([userContext, xboxLiveContextSettings, appConfig](std::shared_ptr<http_call_response> response)
.then([userContext, xboxLiveContextSettings, appConfig, version, lbQuery](std::shared_ptr<http_call_response> response)
{
return utils::generate_xbox_live_result<leaderboard_result>(
@ -508,7 +542,9 @@ pplx::task<xbox_live_result<leaderboard_result>> leaderboard_service::get_leader
response->response_body_json(),
userContext,
xboxLiveContextSettings,
appConfig
appConfig,
version,
lbQuery
),
response
);

Просмотреть файл

@ -0,0 +1,34 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "LeaderboardQuery_WinRT.h"
#include "Utils_WinRT.h"
using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation::Collections;
using namespace Windows::Foundation;
using namespace xbox::services::leaderboard;
using namespace Microsoft::Xbox::Services::System;
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_BEGIN
LeaderboardQuery::LeaderboardQuery(
_In_ xbox::services::leaderboard::leaderboard_query cppObj) :
m_cppObj(std::move(cppObj))
{
}
const xbox::services::leaderboard::leaderboard_query& LeaderboardQuery::GetCppObj() const
{
return m_cppObj;
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_END

Просмотреть файл

@ -0,0 +1,75 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include "shared_macros.h"
#include "xsapi/leaderboard.h"
#include "SortOrder_WinRT.h"
#include "Macros_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_BEGIN
/// <summary>
/// Represents the results of a leaderboard request.
/// </summary>
public ref class LeaderboardQuery sealed
{
public:
/// <summary>
/// Gets/Sets whether or not the resulting leaderboard will start with the
/// user that requested the leaderboard.
/// </summary>
DEFINE_PROP_GETSET_OBJ(SkipResultToMe, skip_result_to_me, bool);
/// <summary>
/// Gets/Sets Which rank the resulting leaderboard will start at
/// </summary>
DEFINE_PROP_GETSET_OBJ(SkipResultToRank, skip_result_to_rank, uint32_t);
/// <summary>
/// Gets/Sets maximum items that the resulting leaderboard will contain
/// </summary>
DEFINE_PROP_GETSET_OBJ(MaxItems, max_items, uint32_t);
/// <summary>
/// Gets/Sets sort order for the resulting leaderboard
/// </summary>
DEFINE_PROP_GETSET_ENUM_OBJ(Order, order, SortOrder, xbox::services::leaderboard::sort_order);
/// <summary>
/// Gets the stat name of the previous query. This property will only be set if its a query
/// gotten from get_next_query
/// </summary>
DEFINE_PROP_GET_STR_OBJ(StatName, stat_name);
/// <summary>
/// Gets the social group of the previous query. This property will only be set if its a query
/// gotten from get_next_query and the previous query was a social query
/// </summary>
DEFINE_PROP_GET_STR_OBJ(SocialGroup, social_group);
/// <summary>
/// True if there is more data in the leaderboard
/// If this is true then you can pass this object into the GetLeaderboard call
/// </summary>
DEFINE_PROP_GET_OBJ(HasNext, has_next, bool);
internal:
LeaderboardQuery(
_In_ xbox::services::leaderboard::leaderboard_query cppObj
);
const xbox::services::leaderboard::leaderboard_query& GetCppObj() const;
private:
xbox::services::leaderboard::leaderboard_query m_cppObj;
};
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_END

Просмотреть файл

@ -0,0 +1,39 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "LeaderboardresultEventArgs_WinRT.h"
#include "Utils_WinRT.h"
using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation::Collections;
using namespace Windows::Foundation;
using namespace xbox::services::leaderboard;
using namespace Microsoft::Xbox::Services::System;
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_BEGIN
LeaderboardResultEventArgs::LeaderboardResultEventArgs(
_In_ std::shared_ptr<xbox::services::stats::manager::leaderboard_result_event_args> cppObj
) :
m_cppObj(std::move(cppObj)
)
{
auto result = m_cppObj->result();
THROW_IF_ERR(result);
m_result = ref new Leaderboard::LeaderboardResult(result.payload());
}
Leaderboard::LeaderboardResult^ LeaderboardResultEventArgs::Result::get()
{
return m_result;
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_END

Просмотреть файл

@ -0,0 +1,44 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include "shared_macros.h"
#include "xsapi/stats_manager.h"
#include "SortOrder_WinRT.h"
#include "StatisticEventArgs_WinRT.h"
#include "../../../Leaderboard/WinRT/LeaderboardResult.h"
#include "Macros_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_BEGIN
/// <summary>
/// Represents the results of a leaderboard request.
/// </summary>
public ref class LeaderboardResultEventArgs sealed : StatisticEventArgs
{
public:
/// <summary>
/// Gets the leaderboard result from a leaderboard request
/// </summary>
property Leaderboard::LeaderboardResult^ Result
{
Leaderboard::LeaderboardResult^ get();
};
internal:
LeaderboardResultEventArgs(
_In_ std::shared_ptr<xbox::services::stats::manager::leaderboard_result_event_args> cppObj
);
private:
std::shared_ptr<xbox::services::stats::manager::leaderboard_result_event_args> m_cppObj;
Leaderboard::LeaderboardResult^ m_result;
};
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_END

Просмотреть файл

@ -0,0 +1,25 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include "xsapi/leaderboard.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_BEGIN
/// <summary>
/// The order to sort the leaderboard in
/// </summary>
public enum class SortOrder
{
Ascending = xbox::services::leaderboard::sort_order::ascending,
Descending = xbox::services::leaderboard::sort_order::descending
};
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_END

Просмотреть файл

@ -0,0 +1,19 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include "xsapi/stats_manager.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_BEGIN
public interface class StatisticEventArgs
{
};
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_END

Просмотреть файл

@ -4,6 +4,7 @@
#include "pch.h"
#include "user_context.h"
#include "StatisticEvent_WinRT.h"
#include "LeaderboardResultEventArgs_WinRT.h"
using namespace xbox::services;
@ -47,4 +48,18 @@ StatisticEvent::ErrorMessage::get()
return m_errorMessage;
}
StatisticEventArgs^
StatisticEvent::EventArgs::get()
{
switch (m_cppObj.event_type())
{
case stats::manager::stat_event_type::get_leaderboard_complete:
return ref new LeaderboardResultEventArgs(std::dynamic_pointer_cast<stats::manager::leaderboard_result_event_args>(m_cppObj.event_args()));
default:
return nullptr;
}
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_END

Просмотреть файл

@ -4,6 +4,7 @@
#pragma once
#include "xsapi/stats_manager.h"
#include "StatisticEventType_WinRT.h"
#include "StatisticEventArgs_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_BEGIN
@ -19,7 +20,7 @@ public:
/// The type of event the statistic is
/// </summary>
/// <return>The event type</return>
DEFINE_PROP_GET_ENUM_OBJ(EventType, event_type, StatisticEventType); // TODO: uncomment
DEFINE_PROP_GET_ENUM_OBJ(EventType, event_type, StatisticEventType);
/// <summary>
/// The error code indicating the result of the operation.
@ -38,6 +39,14 @@ public:
Platform::String^ get();
};
/// <summary>
/// The data of event from stats manager
/// </summary>
property StatisticEventArgs^ EventArgs
{
StatisticEventArgs^ get();
};
internal:
StatisticEvent(_In_ xbox::services::stats::manager::stat_event cppObj);

Просмотреть файл

@ -194,4 +194,34 @@ StatisticManager::DeleteStatistic(
THROW_IF_ERR(result);
}
void StatisticManager::GetLeaderboard(
_In_ XboxLiveUser_t user,
_In_ Platform::String^ statName,
_In_ Leaderboard::LeaderboardQuery^ query
)
{
auto result = m_cppObj->get_leaderboard(
user_context::user_convert(user),
STRING_T_FROM_PLATFORM_STRING(statName),
query->GetCppObj()
);
THROW_IF_ERR(result);
}
void StatisticManager::GetSocialLeaderboard(
_In_ XboxLiveUser_t user,
_In_ Platform::String^ statName,
_In_ Platform::String^ socialGroup,
_In_ Leaderboard::LeaderboardQuery^ query
)
{
auto result = m_cppObj->get_social_leaderboard(
user_context::user_convert(user),
STRING_T_FROM_PLATFORM_STRING(statName),
STRING_T_FROM_PLATFORM_STRING(socialGroup),
query->GetCppObj()
);
THROW_IF_ERR(result);
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_END

Просмотреть файл

@ -5,6 +5,7 @@
#include "xsapi/stats_manager.h"
#include "StatisticEvent_WinRT.h"
#include "StatisticValue_WinRT.h"
#include "LeaderboardQuery_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_STATISTIC_MANAGER_BEGIN
@ -132,6 +133,36 @@ public:
_In_ XboxLiveUser_t user,
_In_ Platform::String^ name
);
/// <summary>
/// Starts a request for a global leaderboard. You can retrieve the resulting data by checking
/// the events returned from do_work for an event of type get_leaderboard_complete
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="statName">The name of the statistic to get the leaderboard of</param>
/// <param name="query">The query parameters of the leaderboard request</param>
/// <return>Whether or not the leaderboard request was started correctly</return>
void GetLeaderboard(
_In_ XboxLiveUser_t user,
_In_ Platform::String^ statName,
_In_ Leaderboard::LeaderboardQuery^ query
);
/// <summary>
/// Starts a request for a social leaderboard. You can retrieve the resulting data by checking
/// the events returned from do_work for an event of type get_leaderboard_complete
/// </summary>
/// <param name="user">The local user whose stats to access</param>
/// <param name="statName">The name of the statistic to get the leaderboard of</param>
/// <param name="socialGroup">The name of the social group</param>
/// <param name="query">The query parameters of the leaderboard request</param>
/// <return>Whether or not the leaderboard request was started correctly</return>
void GetSocialLeaderboard(
_In_ XboxLiveUser_t user,
_In_ Platform::String^ statName,
_In_ Platform::String^ socialGroup,
_In_ Leaderboard::LeaderboardQuery^ query
);
internal:
StatisticManager();

Просмотреть файл

@ -0,0 +1,98 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "xsapi/leaderboard.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_CPP_BEGIN
leaderboard_query::leaderboard_query() :
m_skipResultToMe(false),
m_skipResultToRank(0),
m_maxItems(0),
m_order(sort_order::ascending)
{
}
void leaderboard_query::set_skip_result_to_me(_In_ bool skipResultToMe)
{
m_skipResultToMe = skipResultToMe;
}
void leaderboard_query::set_skip_result_to_rank(_In_ uint32_t skipResultToRank)
{
m_skipResultToRank = skipResultToRank;
}
void leaderboard_query::set_max_items(_In_ uint32_t maxItems)
{
m_maxItems = maxItems;
}
void leaderboard_query::set_order(_In_ sort_order order)
{
m_order = order;
}
bool leaderboard_query::skip_result_to_me() const
{
return m_skipResultToMe;
}
uint32_t leaderboard_query::skip_result_to_rank() const
{
return m_skipResultToRank;
}
uint32_t leaderboard_query::max_items() const
{
return m_maxItems;
}
sort_order leaderboard_query::order() const
{
return m_order;
}
const string_t& leaderboard_query::_Continuation_token() const
{
return m_continuationToken;
}
void leaderboard_query::_Set_continuation_token(_In_ const string_t& continuationToken)
{
m_continuationToken = continuationToken;
}
void leaderboard_query::_Set_stat_name(_In_ const string_t& statName)
{
m_statName = statName;
}
void leaderboard_query::_Set_social_group(_In_ const string_t& socialGroup)
{
m_socialGroup = socialGroup;
}
const string_t& leaderboard_query::stat_name() const
{
return m_statName;
}
const string_t& leaderboard_query::social_group() const
{
return m_socialGroup;
}
bool leaderboard_query::has_next() const
{
return !m_continuationToken.empty();
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_LEADERBOARD_CPP_END

Просмотреть файл

@ -0,0 +1,26 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "xsapi/stats_manager.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_STAT_MANAGER_CPP_BEGIN
const xbox_live_result<leaderboard::leaderboard_result>& leaderboard_result_event_args::result()
{
return m_result;
}
leaderboard_result_event_args::leaderboard_result_event_args(const xbox_live_result<leaderboard::leaderboard_result>& result) :
m_result(result)
{
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_STAT_MANAGER_CPP_END

Просмотреть файл

@ -9,11 +9,13 @@ NAMESPACE_MICROSOFT_XBOX_SERVICES_STAT_MANAGER_CPP_BEGIN
stat_event::stat_event(
stat_event_type eventType,
xbox_live_user_t user,
xbox_live_result<void> errorInfo
xbox_live_result<void> errorInfo,
std::shared_ptr<stat_event_args> args
) :
m_eventType(eventType),
m_localUser(std::move(user)),
m_errorInfo(std::move(errorInfo))
m_errorInfo(std::move(errorInfo)),
m_eventArgs(args)
{
}
@ -29,6 +31,11 @@ stat_event::event_type() const
return m_eventType;
}
std::shared_ptr<stat_event_args> stat_event::event_args() const
{
return m_eventArgs;
}
const xbox_live_user_t&
stat_event::local_user() const
{

Просмотреть файл

@ -65,54 +65,54 @@ stats_manager::do_work()
xbox_live_result<void>
stats_manager::set_stat_as_integer(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name,
_In_ int64_t value
_In_ const string_t& statName,
_In_ int64_t statValue
)
{
return m_statsManagerImpl->set_stat(
user,
name,
static_cast<double>(value)
statName,
static_cast<double>(statValue)
);
}
xbox_live_result<void>
stats_manager::set_stat_as_number(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name,
_In_ double value
_In_ const string_t& statName,
_In_ double statValue
)
{
return m_statsManagerImpl->set_stat(
user,
name,
value
statName,
statValue
);
}
xbox_live_result<void>
stats_manager::set_stat_as_string(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name,
_In_ const string_t& value
_In_ const string_t& statName,
_In_ const string_t& statValue
)
{
return m_statsManagerImpl->set_stat(
user,
name,
value.c_str()
statName,
statValue.c_str()
);
}
xbox_live_result<stat_value>
stats_manager::get_stat(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name
_In_ const string_t& statName
)
{
return m_statsManagerImpl->get_stat(
user,
name
statName
);
}
@ -131,13 +131,41 @@ stats_manager::get_stat_names(
xbox_live_result<void>
stats_manager::delete_stat(
_In_ const xbox_live_user_t& user,
_In_ const string_t& name
_In_ const string_t& statName
)
{
return m_statsManagerImpl->delete_stat(
user,
name
statName
);
}
xbox_live_result<void> stats_manager::get_leaderboard(
const xbox_live_user_t& user,
const string_t& statName,
leaderboard::leaderboard_query query
)
{
return m_statsManagerImpl->get_leaderboard(
user,
statName,
query
);
}
xbox_live_result<void> stats_manager::get_social_leaderboard(
const xbox_live_user_t& user,
const string_t& statName,
const string_t& socialGroup,
leaderboard::leaderboard_query query
)
{
return m_statsManagerImpl->get_social_leaderboard(
user,
statName,
socialGroup,
query
);
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_STAT_MANAGER_CPP_END

Просмотреть файл

@ -503,4 +503,126 @@ stats_manager_impl::write_offline(
}
#endif
xbox_live_result<void> stats_manager_impl::get_leaderboard(const xbox_live_user_t& user, const string_t& statName, leaderboard::leaderboard_query query)
{
std::lock_guard<std::mutex> guard(m_statsServiceMutex);
string_t userStr = user_context::get_user_id(user);
auto userIter = m_users.find(userStr);
if (userIter == m_users.end())
{
return xbox_live_result<void>(xbox_live_error_code::invalid_argument, "User not found in local map");
}
string_t xuid;
if (query.skip_result_to_me())
{
xuid = user_context::get_user_id(user);
}
std::weak_ptr<stats_manager_impl> weakThisPtr = shared_from_this();
auto context = userIter->second.xboxLiveContextImpl;
context->leaderboard_service().get_leaderboard_internal(
context->application_config()->scid(),
statName,
query.skip_result_to_rank(),
xuid,
user_context::get_user_id(user),
_T(""),
query.max_items(),
query._Continuation_token(),
std::vector<string_t>(),
_T("2017"),
query
).then([weakThisPtr, user](xbox::services::xbox_live_result<xbox::services::leaderboard::leaderboard_result> result)
{
auto pShared = weakThisPtr.lock();
if (pShared.get() == nullptr)
{
LOG_DEBUG("Could not successfully get stats_manager while retrieving a leaderboard");
}
else
{
pShared->add_leaderboard_result(user, result);
}
});
return xbox_live_result<void>();
}
xbox_live_result<void> stats_manager_impl::get_social_leaderboard(const xbox_live_user_t& user, const string_t& statName, const string_t& socialGroup, leaderboard::leaderboard_query query)
{
std::lock_guard<std::mutex> guard(m_statsServiceMutex);
string_t userStr = user_context::get_user_id(user);
auto userIter = m_users.find(userStr);
if (userIter == m_users.end())
{
return xbox_live_result<void>(xbox_live_error_code::invalid_argument, "User not found in local map");
}
string_t xuid;
if (query.skip_result_to_me())
{
xuid = user_context::get_user_id(user);
}
string_t order;
if (query.order() == leaderboard::sort_order::ascending)
{
order = _T("ascending");
}
else
{
order = _T("descending");
}
std::weak_ptr<stats_manager_impl> weakThisPtr = shared_from_this();
auto context = userIter->second.xboxLiveContextImpl;
context->leaderboard_service().get_leaderboard_for_social_group_internal(
user_context::get_user_id(user),
context->application_config()->scid(),
statName,
socialGroup,
query.skip_result_to_rank(),
xuid,
order,
query.max_items(),
query._Continuation_token(),
_T("2017"),
query
).then([weakThisPtr, user](xbox::services::xbox_live_result<xbox::services::leaderboard::leaderboard_result> result)
{
auto pShared = weakThisPtr.lock();
if (pShared.get() == nullptr)
{
LOG_DEBUG("Could not successfully get stats_manager while retrieving a leaderboard");
}
else
{
pShared->add_leaderboard_result(user, result);
}
});
return xbox_live_result<void>();
}
void stats_manager_impl::add_leaderboard_result(
_In_ const xbox_live_user_t& user,
_In_ const xbox_live_result<leaderboard::leaderboard_result>& result
)
{
std::lock_guard<std::mutex> guard(m_statsServiceMutex);
string_t userStr = user_context::get_user_id(user);
auto userIter = m_users.find(userStr);
if (userIter == m_users.end())
{
LOG_DEBUG("stats_manager_impl User not found in local map");
return;
}
stat_event statEvent(
stat_event_type::get_leaderboard_complete,
userIter->second.xboxLiveUser,
xbox_live_result<void>(),
std::make_shared<leaderboard_result_event_args>(result)
);
m_statEventList.push_back(statEvent);
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_STAT_MANAGER_CPP_END

Просмотреть файл

@ -223,6 +223,24 @@ public:
void initialize();
xbox_live_result<void> get_leaderboard(
_In_ const xbox_live_user_t& user,
_In_ const string_t& statName,
_In_ leaderboard::leaderboard_query query
);
xbox_live_result<void> get_social_leaderboard(
_In_ const xbox_live_user_t& user,
_In_ const string_t& statName,
_In_ const string_t& socialGroup,
_In_ leaderboard::leaderboard_query query
);
void add_leaderboard_result(
_In_ const xbox_live_user_t& user,
_In_ const xbox_live_result<leaderboard::leaderboard_result>& result
);
private:
static inline bool should_write_offline(xbox_live_result<void>& postResult)
{
@ -249,6 +267,7 @@ private:
static const std::chrono::milliseconds STATS_POLL_TIME_MS;
std::vector<stat_event> m_statEventList;
std::vector<xbox::services::xbox_live_result<leaderboard::leaderboard_result>> m_leaderboardResults;
std::unordered_map<string_t, stats_user_context> m_users;
std::shared_ptr<xbox::services::call_buffer_timer> m_statTimer;
std::shared_ptr<xbox::services::call_buffer_timer> m_statPriorityTimer;

Просмотреть файл

@ -556,10 +556,10 @@ public:
static void set_locales(_In_ const string_t& locale);
template<typename T>
static XBOX_LIVE_NAMESPACE::xbox_live_result<T> generate_xbox_live_result(
_Inout_ XBOX_LIVE_NAMESPACE::xbox_live_result<T> deserializationResult,
_In_ const std::shared_ptr<XBOX_LIVE_NAMESPACE::http_call_response>& response
)
static XBOX_LIVE_NAMESPACE::xbox_live_result<T> generate_xbox_live_result(
_Inout_ XBOX_LIVE_NAMESPACE::xbox_live_result<T> deserializationResult,
_In_ const std::shared_ptr<XBOX_LIVE_NAMESPACE::http_call_response>& response
)
{
if (deserializationResult.err())
{