Adding RTA subs for Tournaments (#126)

* Adding RTA subs for Tournament
* Adding WinRT APIs & cpp/h files to other projects
* Updating test app with Tournament subscribe scenarios
This commit is contained in:
Aditya Toney 2017-04-03 10:03:08 -07:00 коммит произвёл GitHub
Родитель 2b6f179669
Коммит 9f4df22b96
32 изменённых файлов: 781 добавлений и 62 удалений

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

@ -248,6 +248,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Shared\call_buffer_timer.cpp" />
<ClCompile Include="..\..\Source\Shared\initiator.cpp" />
<ClCompile Include="..\..\Source\Shared\local_config.cpp" />

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

@ -678,6 +678,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Social\Manager\social_user_group_loaded_event_args.cpp">
<Filter>C++ Source\Social\Manager</Filter>
</ClCompile>

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

@ -396,6 +396,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentReference_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentRequestResult_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentRequest_WinRT.cpp" />
@ -411,6 +413,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamSummary_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeEventArgs_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.cpp" />
<ClCompile Include="..\..\Source\Shared\call_buffer_timer.cpp" />
<ClCompile Include="..\..\Source\Shared\errors.cpp" />
<ClCompile Include="..\..\Source\Shared\http_call_impl.cpp" />
@ -738,6 +742,8 @@
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamSummary_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.h" />
<ClInclude Include="..\..\Source\Shared\call_buffer_timer.h" />
<ClInclude Include="..\..\Source\Shared\http_call_impl.h" />
<ClInclude Include="..\..\Source\Shared\http_call_response.h" />

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

@ -1194,6 +1194,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\Tournament_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
@ -1233,6 +1239,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Social\Manager\social_user_group_loaded_event_args.cpp">
<Filter>C++ Source\Social\Manager</Filter>
</ClCompile>
@ -2225,6 +2237,12 @@
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.h">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.h">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.h">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Social\Manager\WinRT\SocialEventArgs_WinRT.h">
<Filter>C++ Source\Social\Manager\WinRT</Filter>
</ClInclude>

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

@ -313,6 +313,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_reference.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_request.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_request_result.cpp" />

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

@ -771,6 +771,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\http_call_response.h">

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

@ -460,6 +460,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\current_match_metadata.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\previous_match_metadata.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentReference_WinRT.cpp" />
@ -477,6 +479,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamSummary_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeEventArgs_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.cpp" />
<ClCompile Include="..\..\Source\Shared\call_buffer_timer.cpp" />
<ClCompile Include="..\..\Source\Shared\errors.cpp" />
<ClCompile Include="..\..\Source\Shared\http_call_impl.cpp" />
@ -797,6 +801,8 @@
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamSummary_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.h" />
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.h" />
<ClInclude Include="..\..\Source\Shared\call_buffer_timer.h" />
<ClInclude Include="..\..\Source\Shared\http_call_impl.h" />
<ClInclude Include="..\..\Source\Shared\http_call_response.h" />

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

@ -1284,6 +1284,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\Tournament_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
@ -1323,6 +1329,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.cpp">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Source\Shared\WinRT\Macros_WinRT.h">
@ -2279,6 +2291,12 @@
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.h">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.h">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.h">
<Filter>C++ Source\Tournaments\WinRT</Filter>
</ClInclude>
<ClInclude Include="..\..\Source\Shared\perf_tester.h">
<Filter>C++ Source\Shared</Filter>
</ClInclude>

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

@ -248,6 +248,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Shared\call_buffer_timer.cpp" />
<ClCompile Include="..\..\Source\Shared\initiator.cpp" />
<ClCompile Include="..\..\Source\Shared\local_config.cpp" />

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

@ -693,6 +693,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Social\Manager\social_user_group_loaded_event_args.cpp">
<Filter>C++ Source\Social\Manager</Filter>
</ClCompile>

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

@ -316,6 +316,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_info.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_request.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_request_result.cpp" />

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

@ -744,6 +744,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\team_info.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>

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

@ -248,6 +248,8 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_service_impl.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="..\..\Source\Shared\call_buffer_timer.cpp" />
<ClCompile Include="..\..\Source\Shared\initiator.cpp" />
<ClCompile Include="..\..\Source\Shared\local_config.cpp" />

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

@ -693,6 +693,12 @@
<ClCompile Include="..\..\Source\Services\Tournaments\team_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>C++ Source\Tournaments</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\Services\Social\Manager\social_user_group_loaded_event_args.cpp">
<Filter>C++ Source\Social\Manager</Filter>
</ClCompile>

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

@ -309,6 +309,8 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamRequestResult_WinRT.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamInfo_WinRT.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamSummary_WinRT.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\build_version.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\call_buffer_timer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\http_call_impl.h" />
@ -712,6 +714,8 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\team_change_event_args.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\team_change_subscription.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\tournament_service_impl.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\tournament_change_event_args.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\tournament_change_subscription.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamChangeEventArgs_WinRT.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentReference_WinRT.cpp" />
@ -727,6 +731,8 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamRequestResult_WinRT.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamInfo_WinRT.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamSummary_WinRT.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\call_buffer_timer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\errors.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Shared\http_call_impl.cpp" />

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

@ -1009,6 +1009,12 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\tournament_service_internal.h">
<Filter>XSAPI\Services\Touraments</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.h">
<Filter>XSAPI\Services\Touraments\WinRT</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.h">
<Filter>XSAPI\Services\Touraments\WinRT</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="XSAPI">
@ -2408,6 +2414,12 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TeamChangeSubscription_WinRT.cpp">
<Filter>XSAPI\Services\Touraments\WinRT</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeEventArgs_WinRT.cpp">
<Filter>XSAPI\Services\Touraments\WinRT</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\WinRT\TournamentChangeSubscription_WinRT.cpp">
<Filter>XSAPI\Services\Touraments\WinRT</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\tournament_service_impl.cpp">
<Filter>XSAPI\Services\Touraments</Filter>
</ClCompile>
@ -2417,5 +2429,11 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\team_change_event_args.cpp">
<Filter>XSAPI\Services\Touraments</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\tournament_change_subscription.cpp">
<Filter>XSAPI\Services\Touraments</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Source\Services\Tournaments\tournament_change_event_args.cpp">
<Filter>XSAPI\Services\Touraments</Filter>
</ClCompile>
</ItemGroup>
</Project>

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

@ -969,6 +969,76 @@ private:
string_t m_teamId;
};
/// <summary>
/// Contains information about a change to a subscribed tournament.
/// </summary>
class tournament_change_event_args
{
public:
/// <summary>
/// The organizer ID used to create the subscription.
/// </summary>
_XSAPIIMP const string_t& organizer_id() const;
/// <summary>
/// The tournament ID used to create the subscription.
/// </summary>
_XSAPIIMP const string_t& tournament_id() const;
/// <summary>
/// Internal function
/// </summary>
tournament_change_event_args();
/// <summary>
/// Internal function
/// </summary>
tournament_change_event_args(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId
);
private:
string_t m_organizerId;
string_t m_tournamentId;
};
/// <summary>
/// Handles notification when the state of a tournament subscription changes.
/// </summary>
class tournament_change_subscription : public xbox::services::real_time_activity::real_time_activity_subscription
{
public:
/// <summary>
/// The organizer ID the subscription is for.
/// </summary>
_XSAPIIMP const string_t& organizer_id() const;
/// <summary>
/// The tournament ID the subscription is for.
/// </summary>
_XSAPIIMP const string_t& tournament_id() const;
/// <summary>
/// Internal function
/// </summary>
tournament_change_subscription(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId,
_In_ std::function<void(const tournament_change_event_args&)> handler,
_In_ std::function<void(const xbox::services::real_time_activity::real_time_activity_subscription_error_event_args&)> subscriptionErrorHandler
);
protected:
void on_subscription_created(_In_ uint32_t id, _In_ const web::json::value& data) override;
void on_event_received(_In_ const web::json::value& data) override;
private:
std::function<void(const tournament_change_event_args&)> m_tournamentChangeHandler;
string_t m_organizerId;
string_t m_tournamentId;
};
/// <summary>
/// Represents an endpoint that you can use to access the Tournament service.
/// </summary>
@ -1035,6 +1105,44 @@ public:
_In_ const string_t& teamId
);
/// <summary>
/// Subscribes to tournament update notifications via the TournamentChanged event.
/// </summary>
/// <param name="organizerId">The ID of the tournament organizer. This is case sensitive.</param>
/// <param name="tournamentId">The ID of the tournament.</param>
/// <returns>A tournament_change_subscription object that contains the state of the subscription.
/// You can register an event handler for tournament changes by calling add_tournament_changed_handler().
/// </returns>
_XSAPIIMP xbox_live_result<std::shared_ptr<tournament_change_subscription>> subscribe_to_tournament_change(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId
);
/// <summary>
/// Unsubscribe a previously created tournament change subscription.
/// </summary>
/// <param name="subscription">The subscription object to unsubscribe</param>
_XSAPIIMP xbox_live_result<void> unsubscribe_from_tournament_change(
_In_ std::shared_ptr<tournament_change_subscription> subscription
);
/// <summary>
/// Registers an event handler for tournament change notifications.
/// Event handlers receive a tournament_change_event_args object.
/// </summary>
/// <param name="handler">The callback function that recieves notifications.</param>
/// <returns>
/// A function_context object that can be used to unregister the event handler.
/// </returns>
_XSAPIIMP function_context add_tournament_changed_handler(_In_ std::function<void(tournament_change_event_args)> handler);
/// <summary>
/// Unregisters an event handler for tournament change notifications.
/// </summary>
/// <param name="context">The function_context object that was returned when the event handler was registered. </param>
/// <param name="handler">The callback function that recieves notifications.</param>
_XSAPIIMP void remove_tournament_changed_handler(_In_ function_context context);
/// <summary>
/// Subscribes to team update notifications via the TeamChanged event.
/// </summary>

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

@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "pch.h"
#include "TournamentChangeEventArgs_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_BEGIN
TournamentChangeEventArgs::TournamentChangeEventArgs(
_In_ xbox::services::tournaments::tournament_change_event_args cppObj
) :
m_cppObj(std::move(cppObj))
{
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_END

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

@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#pragma once
#include "xsapi/tournaments.h"
#include "Tournament_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_BEGIN
/// <summary>
/// Contains information about a change to a subscribed team.
/// </summary>
public ref class TournamentChangeEventArgs sealed
{
public:
/// <summary>
/// The organizer ID used to create the subscription.
/// </summary>
DEFINE_PROP_GET_STR_OBJ(OrganizerId, organizer_id);
/// <summary>
/// The tournament ID used to create the subscription.
/// </summary>
DEFINE_PROP_GET_STR_OBJ(TournamentId, tournament_id);
internal:
TournamentChangeEventArgs(_In_ xbox::services::tournaments::tournament_change_event_args cppObj);
private:
xbox::services::tournaments::tournament_change_event_args m_cppObj;
};
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_END

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

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "pch.h"
#include "TournamentChangeSubscription_WinRT.h"
using namespace Microsoft::Xbox::Services::RealTimeActivity;
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_BEGIN
TournamentChangeSubscription::TournamentChangeSubscription(
_In_ std::shared_ptr<xbox::services::tournaments::tournament_change_subscription> cppObj
) :
m_cppObj(cppObj)
{
}
RealTimeActivitySubscriptionState
TournamentChangeSubscription::State::get()
{
return static_cast<RealTimeActivitySubscriptionState>(m_cppObj->state());
}
std::shared_ptr<xbox::services::tournaments::tournament_change_subscription>
TournamentChangeSubscription::GetCppObj() const
{
return m_cppObj;
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_END

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

@ -0,0 +1,44 @@
#pragma once
// Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#pragma once
#include "xsapi/tournaments.h"
#include "Tournament_WinRT.h"
#include "RealTimeActivitySubscriptionState_WinRT.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_BEGIN
/// <summary>
/// Handles notification when the state of a team subscription changes.
/// </summary>
public ref class TournamentChangeSubscription sealed
{
public:
/// <summary>
/// Indicates the state of the subscription.
/// </summary>
property Microsoft::Xbox::Services::RealTimeActivity::RealTimeActivitySubscriptionState State
{
Microsoft::Xbox::Services::RealTimeActivity::RealTimeActivitySubscriptionState get();
}
/// <summary>
/// The organizer ID the subscription is for.
/// </summary>
DEFINE_PTR_PROP_GET_STR_OBJ(OrganizerId, organizer_id);
/// <summary>
/// The tournament ID the subscription is for.
/// </summary>
DEFINE_PTR_PROP_GET_STR_OBJ(TournamentId, tournament_id);
internal:
TournamentChangeSubscription(_In_ std::shared_ptr<xbox::services::tournaments::tournament_change_subscription> cppObj);
std::shared_ptr<xbox::services::tournaments::tournament_change_subscription> GetCppObj() const;
private:
std::shared_ptr<xbox::services::tournaments::tournament_change_subscription> m_cppObj;
};
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_END

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

@ -5,6 +5,8 @@
#include "TournamentService_WinRT.h"
#include "Utils_WinRT.h"
#include "TeamChangeEventArgs_WinRT.h"
#include "TournamentChangeEventArgs_WinRT.h"
#include "XboxLiveContextSettings_WinRT.h"
using namespace Platform;
using namespace concurrency;

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

@ -65,8 +65,12 @@ team_change_subscription::on_subscription_created(
void
team_change_subscription::on_event_received(
_In_ const web::json::value& data
)
)
{
// The team subscription has no payload.
// Clients should get the tournament or team from the Hub when they receive a tap.
UNREFERENCED_PARAMETER(data);
team_change_event_args teamChangeEventArgs;
if (m_teamChangeHandler)

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

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "pch.h"
#include "xsapi/tournaments.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_CPP_BEGIN
tournament_change_event_args::tournament_change_event_args()
{
}
tournament_change_event_args::tournament_change_event_args(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId
) :
m_organizerId(std::move(organizerId)),
m_tournamentId(std::move(tournamentId))
{
}
const string_t&
tournament_change_event_args::organizer_id() const
{
return m_organizerId;
}
const string_t&
tournament_change_event_args::tournament_id() const
{
return m_tournamentId;
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_CPP_END

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

@ -0,0 +1,109 @@
// Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "pch.h"
#include "xsapi/tournaments.h"
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_CPP_BEGIN
tournament_change_subscription::tournament_change_subscription(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId,
_In_ std::function<void(const tournament_change_event_args&)> handler,
_In_ std::function<void(const xbox::services::real_time_activity::real_time_activity_subscription_error_event_args&)> subscriptionErrorHandler
) :
real_time_activity_subscription(subscriptionErrorHandler),
m_organizerId(std::move(organizerId)),
m_tournamentId(std::move(tournamentId)),
m_tournamentChangeHandler(handler)
{
XSAPI_ASSERT(handler != nullptr);
stringstream_t uriPath;
uriPath << _T("https://tournamentshub.xboxlive.com/tournaments/") << m_organizerId << _T("/") << m_tournamentId;
m_resourceUri = uriPath.str();
}
void
tournament_change_subscription::on_subscription_created(
_In_ uint32_t id,
_In_ const web::json::value& data
)
{
real_time_activity_subscription::on_subscription_created(
id,
data
);
if (m_tournamentChangeHandler)
{
m_tournamentChangeHandler(
tournament_change_event_args(
m_organizerId,
m_tournamentId
)
);
}
else
{
if (m_subscriptionErrorHandler != nullptr)
{
m_subscriptionErrorHandler(
xbox::services::real_time_activity::real_time_activity_subscription_error_event_args(
*this,
xbox_live_error_code::json_error,
"JSON not found on subscription"
)
);
}
}
}
void
tournament_change_subscription::on_event_received(
_In_ const web::json::value& data
)
{
// The team subscription has no payload.
// Clients should get the tournament or team from the Hub when they receive a tap.
UNREFERENCED_PARAMETER(data);
tournament_change_event_args tournamentChangeEventArgs;
if (m_tournamentChangeHandler)
{
m_tournamentChangeHandler(
tournament_change_event_args(
m_organizerId,
m_tournamentId
)
);
}
else
{
if (m_subscriptionErrorHandler != nullptr)
{
m_subscriptionErrorHandler(
xbox::services::real_time_activity::real_time_activity_subscription_error_event_args(
*this,
xbox_live_error_code::json_error,
"JSON not found on change event"
)
);
}
}
}
const string_t&
tournament_change_subscription::organizer_id() const
{
return m_organizerId;
}
const string_t&
tournament_change_subscription::tournament_id() const
{
return m_tournamentId;
}
NAMESPACE_MICROSOFT_XBOX_SERVICES_TOURNAMENTS_CPP_END

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

@ -500,10 +500,50 @@ tournament_service::_Convert_string_to_team_state(
return xbox::services::tournaments::team_state::unknown;
}
function_context
tournament_service::add_tournament_changed_handler(
_In_ std::function<void(tournament_change_event_args)> handler
)
{
return m_tournamentServiceImpl->add_tournament_changed_handler(
std::move(handler)
);
}
void
tournament_service::remove_tournament_changed_handler(
_In_ function_context context
)
{
return m_tournamentServiceImpl->remove_tournament_changed_handler(
context
);
}
xbox_live_result<std::shared_ptr<tournament_change_subscription>>
tournament_service::subscribe_to_tournament_change(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId
)
{
return m_tournamentServiceImpl->subscribe_to_tournament_change(
organizerId,
tournamentId
);
}
xbox_live_result<void>
tournament_service::unsubscribe_from_tournament_change(
_In_ std::shared_ptr<tournament_change_subscription> subscription
)
{
return m_tournamentServiceImpl->unsubscribe_from_tournament_change(subscription);
}
function_context
tournament_service::add_team_changed_handler(
_In_ std::function<void(team_change_event_args)> handler
)
)
{
return m_tournamentServiceImpl->add_team_changed_handler(
std::move(handler)
@ -513,7 +553,7 @@ tournament_service::add_team_changed_handler(
void
tournament_service::remove_team_changed_handler(
_In_ function_context context
)
)
{
return m_tournamentServiceImpl->remove_team_changed_handler(
context
@ -521,9 +561,9 @@ tournament_service::remove_team_changed_handler(
}
xbox_live_result<std::shared_ptr<team_change_subscription>>
tournament_service::subscribe_to_team_change(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId,
tournament_service::subscribe_to_team_change(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId,
_In_ const string_t& teamId
)
{
@ -531,13 +571,13 @@ tournament_service::subscribe_to_team_change(
organizerId,
tournamentId,
teamId
);
);
}
xbox_live_result<void>
tournament_service::unsubscribe_from_team_change(
_In_ std::shared_ptr<team_change_subscription> subscription
)
)
{
return m_tournamentServiceImpl->unsubscribe_from_team_change(subscription);
}

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

@ -11,15 +11,121 @@ tournament_service_impl::tournament_service_impl(
_In_ std::shared_ptr<xbox::services::real_time_activity::real_time_activity_service> rtaService
) :
m_realTimeActivityService(rtaService),
m_tournamentChangeHandlerCounter(0),
m_teamChangeHandlerCounter(0)
{
}
tournament_service_impl::~tournament_service_impl()
{
m_tournamentChangeHandler.clear();
m_teamChangeHandler.clear();
}
function_context
tournament_service_impl::add_tournament_changed_handler(
_In_ std::function<void(const tournament_change_event_args&)> handler
)
{
std::lock_guard<std::mutex> lock(m_tournamentHandlerLock.get());
function_context context = -1;
if (handler != nullptr)
{
context = ++m_tournamentChangeHandlerCounter;
m_tournamentChangeHandler[m_tournamentChangeHandlerCounter] = std::move(handler);
}
return context;
}
void
tournament_service_impl::remove_tournament_changed_handler(
_In_ function_context context
)
{
std::lock_guard<std::mutex> lock(m_tournamentHandlerLock.get());
m_tournamentChangeHandler.erase(context);
}
void
tournament_service_impl::tournament_changed(
_In_ const tournament_change_event_args& eventArgs
)
{
std::unordered_map<function_context, std::function<void(const tournament_change_event_args&)>> tournamentChangeHandlerCopy;
{
std::lock_guard<std::mutex> lock(m_tournamentHandlerLock.get());
tournamentChangeHandlerCopy = m_tournamentChangeHandler;
}
for (auto& handler : tournamentChangeHandlerCopy)
{
XSAPI_ASSERT(handler.second != nullptr);
if (handler.second != nullptr)
{
try
{
handler.second(eventArgs);
}
catch (...)
{
LOG_ERROR("tournament_changed handler threw an exception");
}
}
}
}
xbox_live_result<std::shared_ptr<tournament_change_subscription>>
tournament_service_impl::subscribe_to_tournament_change(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId
)
{
std::weak_ptr<tournament_service_impl> thisWeakPtr = shared_from_this();
std::shared_ptr<tournament_change_subscription> statChangeSub = std::make_shared<tournament_change_subscription>(
organizerId,
tournamentId,
([thisWeakPtr](const tournament_change_event_args& eventArgs)
{
std::shared_ptr<tournament_service_impl> pThis(thisWeakPtr.lock());
if (pThis != nullptr)
{
pThis->tournament_changed(eventArgs);
}
}),
([thisWeakPtr](const xbox::services::real_time_activity::real_time_activity_subscription_error_event_args& eventArgs)
{
std::shared_ptr<tournament_service_impl> pThis(thisWeakPtr.lock());
if (pThis != nullptr)
{
pThis->m_realTimeActivityService->_Trigger_subscription_error(eventArgs);
}
})
);
auto subscriptionSucceeded = m_realTimeActivityService->_Add_subscription(
statChangeSub
);
if (!subscriptionSucceeded.err())
{
return xbox_live_result<std::shared_ptr<tournament_change_subscription>>(statChangeSub);
}
return xbox_live_result<std::shared_ptr<tournament_change_subscription>>(subscriptionSucceeded.err(), subscriptionSucceeded.err_message());
}
xbox_live_result<void>
tournament_service_impl::unsubscribe_from_tournament_change(
_In_ std::shared_ptr<tournament_change_subscription> subscription
)
{
return m_realTimeActivityService->_Remove_subscription(subscription);
}
function_context
tournament_service_impl::add_team_changed_handler(
_In_ std::function<void(const team_change_event_args&)> handler
@ -49,7 +155,7 @@ tournament_service_impl::remove_team_changed_handler(
void
tournament_service_impl::team_changed(
_In_ const team_change_event_args& eventArgs
)
)
{
std::unordered_map<function_context, std::function<void(const team_change_event_args&)>> teamChangeHandlerCopy;
{
@ -120,7 +226,7 @@ tournament_service_impl::subscribe_to_team_change(
xbox_live_result<void>
tournament_service_impl::unsubscribe_from_team_change(
_In_ std::shared_ptr<team_change_subscription> subscription
)
)
{
return m_realTimeActivityService->_Remove_subscription(subscription);
}

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

@ -14,6 +14,21 @@ public:
~tournament_service_impl();
// Tournament subscriptions
xbox_live_result<std::shared_ptr<tournament_change_subscription>> subscribe_to_tournament_change(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId
);
xbox_live_result<void> unsubscribe_from_tournament_change(
_In_ std::shared_ptr<tournament_change_subscription> subscription
);
function_context add_tournament_changed_handler(_In_ std::function<void(const tournament_change_event_args&)> handler);
void remove_tournament_changed_handler(_In_ function_context context);
// Team subscriptions
xbox_live_result<std::shared_ptr<team_change_subscription>> subscribe_to_team_change(
_In_ const string_t& organizerId,
_In_ const string_t& tournamentId,
@ -29,12 +44,18 @@ public:
void remove_team_changed_handler(_In_ function_context context);
private:
void tournament_changed(_In_ const tournament_change_event_args& eventArgs);
void team_changed(_In_ const team_change_event_args& eventArgs);
xbox::services::system::xbox_live_mutex m_tournamentHandlerLock;
std::unordered_map<function_context, std::function<void(const tournament_change_event_args&)>> m_tournamentChangeHandler;
function_context m_tournamentChangeHandlerCounter;
xbox::services::system::xbox_live_mutex m_teamHandlerLock;
std::shared_ptr<xbox::services::real_time_activity::real_time_activity_service> m_realTimeActivityService;
std::unordered_map<function_context, std::function<void(const team_change_event_args&)>> m_teamChangeHandler;
function_context m_teamChangeHandlerCounter;
std::shared_ptr<xbox::services::real_time_activity::real_time_activity_service> m_realTimeActivityService;
};
}}}

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

@ -102,14 +102,14 @@ void Sample::SetupUI()
// Join Lobby
m_ui->FindControl<ImageButton>(c_mainMenuPanelId, c_joinLobbyBtn)->SetCallback([this](IPanel*, IControl*)
{
m_appState = APPSTATE::APP_CREATE_LOBBY;
m_appState = APPSTATE::APP_GET_TOURNAMENTS;
ChangeAppStates();
});
// Join Custom Game
m_ui->FindControl<ImageButton>(c_mainMenuPanelId, c_joinCustomGameBtn)->SetCallback([this](IPanel*, IControl*)
{
m_appState = APPSTATE::APP_JOIN_GAME;
m_appState = APPSTATE::APP_GET_TEAMS;
ChangeAppStates();
});

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

@ -124,11 +124,16 @@ private:
void CreateDeviceDependentResources();
void CreateWindowSizeDependentResources();
// Tournament Methods
void GetTournaments();
void GetTournamentDetails(const string_t& organizerId, const string_t& tournamentId);
void SubscribeForTournamentRTASubscription(const string_t& organizerId, const string_t& tournamentId);
void GetTeams();
void TestTeamRTASubscription(string_t teamId);
void GetTeamDetailsAndSubscribeForRTA(xbox::services::xbox_live_result<xbox::services::tournaments::team_request_result> &result);
void GetTeamDetails(const string_t& organizerId, const string_t& tournamentId, const string_t& teamId);
void SubscribeForTeamRTASubscription(const string_t& organizerId, const string_t& tournamentId, const string_t& teamId);
// Device resources.
std::unique_ptr<DX::DeviceResources> m_deviceResources;

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="38133JasonSandlin.Tournaments-XboxLiveSDKCSample" Publisher="CN=21A176D6-65FC-40A6-A44A-7DC730DA0070" Version="1.7.0.0" />
<Identity Name="38133JasonSandlin.NetrumbleArenaEdition" Publisher="CN=21A176D6-65FC-40A6-A44A-7DC730DA0070" Version="1.7.0.0" />
<mp:PhoneIdentity PhoneProductId="997b70fc-d78e-48b7-ac75-4e3ed52d945a" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>Xbox LIVE SDK Sample - Multiplayer</DisplayName>
@ -25,7 +25,7 @@
<uap:Protocol Name="ms-xbl-multiplayer" />
</uap:Extension>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="ms-xbl-169056cf" />
<uap:Protocol Name="ms-xbl-00d3bb69" />
</uap:Extension>
</Extensions>
</Application>

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

@ -13,6 +13,25 @@ using namespace xbox::services::tournaments;
void Sample::GetTournaments()
{
auto context = m_liveResources->GetLiveContext();
if (m_organizerId.empty() && m_tournamentId.empty())
{
// If coming for the first time, subscribe for RTA.
context->real_time_activity_service()->activate();
context->tournament_service().add_tournament_changed_handler(
[this](tournament_change_event_args args)
{
GetTournamentDetails(args.organizer_id(), args.tournament_id());
});
context->tournament_service().add_team_changed_handler(
[this, context](team_change_event_args args)
{
GetTeamDetails(args.organizer_id(), args.tournament_id(), args.team_id());
});
}
static bool filterUsersForMe = true;
tournament_request request = tournament_request(filterUsersForMe);
std::vector<tournament_state> states;
@ -20,7 +39,6 @@ void Sample::GetTournaments()
states.push_back(tournament_state::canceled);
request.set_state_filter(states);
auto context = m_liveResources->GetLiveContext();
auto result = context->tournament_service().get_tournaments(request)
.then([this](xbox_live_result<tournament_request_result> result)
{
@ -31,11 +49,16 @@ void Sample::GetTournaments()
// For testing, assign the first tournament as the locally cached tournament.
for (const auto& tournament : tournamentResult.tournaments())
{
if (!tournament.team_summary().is_null())
const string_t& organizerId = tournament.organizer_id();
const string_t& tournamentId = tournament.id();
if (!tournament.team_summary().is_null() &&
m_organizerId.empty() &&
m_tournamentId.empty())
{
m_organizerId = tournament.organizer_id();
m_tournamentId = tournament.id();
break;
m_organizerId = organizerId;
m_tournamentId = tournamentId;
GetTournamentDetails(organizerId, tournamentId);
SubscribeForTournamentRTASubscription(organizerId, tournamentId);
}
}
@ -51,16 +74,6 @@ void Sample::GetTournaments()
}).wait();
}
// Get Tournament Details
auto context = m_liveResources->GetLiveContext();
auto getTournamentResult = context->tournament_service().get_tournament_details(m_organizerId, m_tournamentId)
.then([this](xbox_live_result<tournament> result)
{
if (result.err())
{
LogErrorFormat(L"get_tournament_details failed: %S\n", result.err_message().c_str());
}
});
}
else
{
@ -76,6 +89,39 @@ void Sample::GetTournaments()
});
}
void Sample::GetTournamentDetails(
const string_t& organizerId,
const string_t& tournamentId
)
{
auto context = m_liveResources->GetLiveContext();
context->tournament_service().get_tournament_details(organizerId, tournamentId)
.then([this](xbox_live_result<tournament> result)
{
if (result.err())
{
LogErrorFormat(L"get_tournament_details failed: %S\n", result.err_message().c_str());
}
});
}
void Sample::SubscribeForTournamentRTASubscription(
const string_t& organizerId,
const string_t& tournamentId
)
{
auto context = m_liveResources->GetLiveContext();
auto tournamentResults = context->tournament_service().subscribe_to_tournament_change(
organizerId,
tournamentId
);
if (tournamentResults.err())
{
LogErrorFormat(L"Error calling subscribe_to_tournament_change:: %S\n", tournamentResults.err_message().c_str());
}
}
void Sample::GetTeams()
{
static bool filterUsersForMe = false;
@ -92,35 +138,20 @@ void Sample::GetTeams()
{
if (!result.err())
{
auto& teamResult = result.payload();
for (const auto& team : teamResult.teams())
{
TestTeamRTASubscription(team.id());
}
GetTeamDetailsAndSubscribeForRTA(result);
// Get next page until the end
xbox_live_result<team_request_result> lastResult;
lastResult.set_payload(teamResult);
lastResult.set_payload(result.payload());
while (!lastResult.err() && lastResult.payload().has_next())
{
lastResult.payload().get_next()
.then([this, &lastResult](xbox_live_result<team_request_result> newTeamResult)
{
lastResult = newTeamResult;
GetTeamDetailsAndSubscribeForRTA(lastResult);
}).wait();
}
// Get Team Details
auto context = m_liveResources->GetLiveContext();
auto getTeamResult = context->tournament_service().get_team_details(m_organizerId, m_tournamentId, m_teamId)
.then([this](xbox_live_result<team_info> result)
{
if (result.err())
{
LogErrorFormat(L"get_team_details failed: %S\n", result.err_message().c_str());
}
});
}
else
{
@ -136,21 +167,45 @@ void Sample::GetTeams()
});
}
void Sample::TestTeamRTASubscription(string_t teamId)
void Sample::GetTeamDetailsAndSubscribeForRTA(xbox_live_result<team_request_result> &result)
{
auto& teamResult = result.payload();
for (const auto& team : teamResult.teams())
{
const string_t& teamId = team.id();
GetTeamDetails(m_organizerId, m_tournamentId, teamId);
SubscribeForTeamRTASubscription(m_organizerId, m_tournamentId, teamId);
}
}
void Sample::GetTeamDetails(
const string_t& organizerId,
const string_t& tournamentId,
const string_t& teamId
)
{
// Get Team Details
auto context = m_liveResources->GetLiveContext();
context->tournament_service().get_team_details(organizerId, tournamentId, teamId)
.then([this](xbox_live_result<team_info> result)
{
if (result.err())
{
LogErrorFormat(L"get_team_details failed: %S\n", result.err_message().c_str());
}
});
}
void Sample::SubscribeForTeamRTASubscription(
const string_t& organizerId,
const string_t& tournamentId,
const string_t& teamId
)
{
auto context = m_liveResources->GetLiveContext();
context->real_time_activity_service()->activate();
auto teamChangeContext = context->tournament_service().add_team_changed_handler(
[this, context](team_change_event_args args)
{
auto orgId = args.organizer_id();
}
);
auto teamResults = context->tournament_service().subscribe_to_team_change(
m_organizerId,
m_tournamentId,
organizerId,
tournamentId,
teamId
);