Skip to content

Commit

Permalink
2104 QFE1 (#566)
Browse files Browse the repository at this point in the history
* 2104 QFE1
  • Loading branch information
natiskan authored May 7, 2021
1 parent b67fe71 commit 851ae32
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Include/xsapi-c/leaderboard_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ typedef struct XblLeaderboardRow
uint32_t rank;

/// <summary>
/// The global rank of the player.
/// The global rank of the player. If globalrank is 0, then the user has no global rank.
/// </summary>
uint32_t globalRank;

/// <summary>
/// UTF-8 encoded values for each column in the leaderboard row for the player.
/// UTF-8 encoded JSON values for each column in the leaderboard row for the player.
/// </summary>
_Field_z_ const char** columnValues;

Expand Down
4 changes: 3 additions & 1 deletion Include/xsapi-c/services_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
#include <xsapi-c/http_call_c.h>
#include <xsapi-c/title_storage_c.h>
#include <xsapi-c/game_invite_c.h>
#include <xsapi-c/notification_c.h>
#if XSAPI_NOTIFICATION_SERVICE
#include <xsapi-c/notification_c.h>
#endif
40 changes: 22 additions & 18 deletions Include/xsapi-cpp/impl/notification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
#pragma once
#include "public_utils.h"

NAMESPACE_MICROSOFT_XBOX_SERVICES_NOTIFICATION_CPP_BEGIN
NAMESPACE_MICROSOFT_XBOX_SERVICES_NOTIFICATION_CPP_BEGIN
#if XSAPI_NOTIFICATION_SERVICE
notification_service::notification_service(_In_ XblContextHandle contextHandle)
{
XblContextDuplicateHandle(contextHandle, &m_xblContext);
}

notification_service::~notification_service()
{
#if !XSAPI_UNIT_TESTS
unsubscribe_from_notifications().wait();
#endif
XblContextCloseHandle(m_xblContext);
}

Expand Down Expand Up @@ -48,32 +52,32 @@ inline invite_notification_event_args::invite_notification_event_args(_In_ const
{
}

const string_t& invite_notification_event_args::invited_xbox_user_id() const
string_t invite_notification_event_args::invited_xbox_user_id() const
{
return Utils::StringTFromUint64(m_gameInviteArgs.invitedXboxUserId);
}

const string_t& invite_notification_event_args::sender_xbox_user_id() const
string_t invite_notification_event_args::sender_xbox_user_id() const
{
return Utils::StringTFromUint64(m_gameInviteArgs.senderXboxUserId);
}

const string_t& invite_notification_event_args::sender_gamertag() const
string_t invite_notification_event_args::sender_gamertag() const
{
return Utils::StringTFromUtf8(m_gameInviteArgs.senderGamertag);
}

const string_t& invite_notification_event_args::invite_handle_id() const
string_t invite_notification_event_args::invite_handle_id() const
{
return Utils::StringTFromUtf8(m_gameInviteArgs.inviteHandleId);
}

const string_t& invite_notification_event_args::invite_protocol() const
string_t invite_notification_event_args::invite_protocol() const
{
return Utils::StringTFromUtf8(m_gameInviteArgs.inviteProtocol);
}

const utility::datetime& invite_notification_event_args::expiration() const
utility::datetime invite_notification_event_args::expiration() const
{
return Utils::DatetimeFromTimeT(m_gameInviteArgs.expiration);
}
Expand All @@ -88,42 +92,42 @@ inline achievement_unlocked_notification_event_args::achievement_unlocked_notifi
{
}

const string_t& achievement_unlocked_notification_event_args::name() const
string_t achievement_unlocked_notification_event_args::name() const
{
return Utils::StringTFromUtf8(m_achievementUnlock.achievementName);
}

const string_t achievement_unlocked_notification_event_args::id() const
string_t achievement_unlocked_notification_event_args::id() const
{
return Utils::StringTFromUtf8(m_achievementUnlock.achievementId);
}

const string_t& achievement_unlocked_notification_event_args::description() const
string_t achievement_unlocked_notification_event_args::description() const
{
return Utils::StringTFromUtf8(m_achievementUnlock.achievementDescription);
}

const string_t& achievement_unlocked_notification_event_args::icon_url() const
string_t achievement_unlocked_notification_event_args::icon_url() const
{
return Utils::StringTFromUtf8(m_achievementUnlock.achievementIcon);
}

const uint64_t achievement_unlocked_notification_event_args::gamerscore() const
uint64_t achievement_unlocked_notification_event_args::gamerscore() const
{
return m_achievementUnlock.gamerscore;
}

const string_t& achievement_unlocked_notification_event_args::deeplink() const
string_t achievement_unlocked_notification_event_args::deeplink() const
{
return Utils::StringTFromUtf8(m_achievementUnlock.deepLink);
}

const string_t& achievement_unlocked_notification_event_args::xbox_user_id() const
string_t achievement_unlocked_notification_event_args::xbox_user_id() const
{
return Utils::StringTFromUint64(m_achievementUnlock.xboxUserId);
}

const utility::datetime& achievement_unlocked_notification_event_args::unlockTime() const
utility::datetime achievement_unlocked_notification_event_args::unlockTime() const
{
return Utils::DatetimeFromTimeT(m_achievementUnlock.timeUnlocked);
}
Expand All @@ -144,7 +148,6 @@ pplx::task<xbox_live_result<void>> notification_service::subscribe_to_notificati
)
{
auto xblContext = m_xblContext;
void* context = m_xblContext;

m_inviteHandler = multiplayerInviteHandler;
m_achievementUnlockedHandler = achievementUnlockHandler;
Expand All @@ -158,7 +161,7 @@ pplx::task<xbox_live_result<void>> notification_service::subscribe_to_notificati
auto service = static_cast<notification_service*>(context);
service->game_invite_handler()(resultInviteArgs);
},
context
shared_from_this().get()
);
delete(asyncWrapper);

Expand All @@ -171,7 +174,7 @@ pplx::task<xbox_live_result<void>> notification_service::subscribe_to_notificati
auto service = static_cast<notification_service*>(context);
service->achievement_unlock_handler()(achievementUnlockArgs);
},
context
shared_from_this().get()
);

return asyncWrapper->Task(S_OK);
Expand Down Expand Up @@ -200,4 +203,5 @@ pplx::task<xbox_live_result<void>> notification_service::unsubscribe_from_notifi
return asyncWrapper->Task(S_OK);
}
#endif
#endif
NAMESPACE_MICROSOFT_XBOX_SERVICES_NOTIFICATION_CPP_END
17 changes: 14 additions & 3 deletions Include/xsapi-cpp/impl/xbox_live_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

#include "xsapi-cpp/xbox_live_context.h"
#include "xsapi-cpp/events.h"
#if XSAPI_NOTIFICATION_SERVICE
#include "xsapi-cpp/notification_service.h"

#endif
NAMESPACE_MICROSOFT_XBOX_SERVICES_CPP_BEGIN

xbox_live_context::xbox_live_context(_In_ XblUserHandle user)
Expand All @@ -21,11 +22,12 @@ xbox_live_context::xbox_live_context(_In_ XblUserHandle user)
if (FAILED(hr)) throw std::runtime_error("XblContextCreateHandle failed");
XblSetApiType(XblApiType::XblCPPApi);

#if XSAPI_NOTIFICATION_SERVICE
// Unlike the rest of the services, notification_service needs to maintain state
// That is because of the differences between C-APIs for subscribing for RTA events
// and the C++ subscribe_to_notifications call
m_notificationService = std::make_shared<notification::notification_service>(m_handle);

#endif
}

xbox_live_context::xbox_live_context(_In_ XblContextHandle xboxLiveContextHandle)
Expand All @@ -34,10 +36,12 @@ xbox_live_context::xbox_live_context(_In_ XblContextHandle xboxLiveContextHandle
if (FAILED(hr)) throw std::runtime_error("XblContextCreateHandle failed");
XblSetApiType(XblApiType::XblCPPApi);

#if XSAPI_NOTIFICATION_SERVICE
// Unlike the rest of the services, notification_service needs to maintain state
// That is because of the differences between C-APIs for subscribing for RTA events
// and the C++ subscribe_to_notifications call
m_notificationService = std::make_shared<notification::notification_service>(m_handle);
#endif
}

xbox_live_context::~xbox_live_context()
Expand All @@ -52,6 +56,13 @@ XblUserHandle xbox_live_context::user()
return userHandle;
}

XblContextHandle xbox_live_context::handle()
{
XblContextHandle contextHandle = nullptr;
XblContextDuplicateHandle(m_handle, &contextHandle);
return contextHandle;
}

string_t xbox_live_context::xbox_live_user_id()
{
stringstream_t ss;
Expand Down Expand Up @@ -137,7 +148,7 @@ presence::presence_service xbox_live_context::presence_service()
return presence::presence_service(m_handle);
}

#if HC_PLATFORM == HC_PLATFORM_WIN32
#if XSAPI_NOTIFICATION_SERVICE
std::shared_ptr<notification::notification_service> xbox_live_context::notification_service()
{
return m_notificationService;
Expand Down
28 changes: 14 additions & 14 deletions Include/xsapi-cpp/notification_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class xbox_live_context;
class invite_notification_event_args
{
public:
inline const string_t& invited_xbox_user_id() const;
inline const string_t& sender_xbox_user_id() const;
inline const string_t& sender_gamertag() const;
inline const string_t& invite_handle_id() const;
inline const string_t& invite_protocol() const;
inline const utility::datetime& expiration() const;
inline string_t invited_xbox_user_id() const;
inline string_t sender_xbox_user_id() const;
inline string_t sender_gamertag() const;
inline string_t invite_handle_id() const;
inline string_t invite_protocol() const;
inline utility::datetime expiration() const;
inline const multiplayer::multiplayer_session_reference session_reference() const;

/// <summary>
Expand All @@ -36,14 +36,14 @@ class invite_notification_event_args
class achievement_unlocked_notification_event_args
{
public:
inline const string_t& name() const;
inline const string_t id() const;
inline const string_t& description() const;
inline const string_t& icon_url() const;
inline const uint64_t gamerscore() const;
inline const string_t& deeplink() const;
inline const string_t& xbox_user_id() const;
inline const utility::datetime& unlockTime() const;
inline string_t name() const;
inline string_t id() const;
inline string_t description() const;
inline string_t icon_url() const;
inline uint64_t gamerscore() const;
inline string_t deeplink() const;
inline string_t xbox_user_id() const;
inline utility::datetime unlockTime() const;

achievement_unlocked_notification_event_args(_In_ const XblAchievementUnlockEvent& achievementUnlockEvent);

Expand Down
14 changes: 13 additions & 1 deletion Include/xsapi-cpp/xbox_live_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include "xsapi-cpp/matchmaking.h"
#include "xsapi-cpp/user_statistics.h"
#include "xsapi-cpp/string_verify.h"
#if XSAPI_NOTIFICATION_SERVICE
#include "xsapi-cpp/notification_service.h"
#endif

NAMESPACE_MICROSOFT_XBOX_SERVICES_CPP_BEGIN

Expand Down Expand Up @@ -45,6 +47,14 @@ class xbox_live_context
/// </summary>
inline XblUserHandle user();

/// <summary>
/// Returns a copy of the associated Xbox Live context handle.
/// </summary>
/// <remarks>
/// It is the caller's responsibility to close the returned handle.
/// </remarks>
inline XblContextHandle handle();

/// <summary>
/// Returns the current user's Xbox Live User ID.
/// </summary>
Expand Down Expand Up @@ -126,7 +136,7 @@ class xbox_live_context
/// </summary>
inline presence::presence_service presence_service();

#if HC_PLATFORM == HC_PLATFORM_WIN32
#if XSAPI_NOTIFICATION_SERVICE
/// <summary>
/// A service for receiving notifications.
/// </summary>
Expand All @@ -151,7 +161,9 @@ class xbox_live_context
private:
XblContextHandle m_handle = nullptr;

#if XSAPI_NOTIFICATION_SERVICE
std::shared_ptr <notification::notification_service> m_notificationService;
#endif
};

NAMESPACE_MICROSOFT_XBOX_SERVICES_CPP_END
Expand Down
4 changes: 4 additions & 0 deletions Source/Services/Common/xbox_live_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include "xbox_live_app_config_internal.h"
#include "xbox_live_context_settings_internal.h"
#include "title_storage_internal.h"
#if XSAPI_NOTIFICATION_SERVICE
#include "notification_internal.h"
#endif

using namespace xbox::services;
using namespace xbox::services::system;
Expand Down Expand Up @@ -280,10 +282,12 @@ std::shared_ptr<presence::PresenceService> XblContext::PresenceService()
return m_presenceService;
}

#if XSAPI_NOTIFICATION_SERVICE
std::shared_ptr<notification::NotificationService> XblContext::NotificationService()
{
return m_notificationService;
}
#endif

std::shared_ptr<multiplayer_activity::MultiplayerActivityService> XblContext::MultiplayerActivityService() noexcept
{
Expand Down
6 changes: 5 additions & 1 deletion Source/Services/Common/xbox_live_context_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include "string_service_internal.h"
#include "social_internal.h"
#include "multiplayer_activity_internal.h"
#if XSAPI_NOTIFICATION_SERVICE
#include "notification_internal.h"
#endif

NAMESPACE_MICROSOFT_XBOX_SERVICES_MATCHMAKING_CPP_BEGIN
namespace legacy
Expand Down Expand Up @@ -100,10 +102,12 @@ struct XblContext : public std::enable_shared_from_this<XblContext>, public xbox
/// </summary>
std::shared_ptr<xbox::services::presence::PresenceService> PresenceService();

#if XSAPI_NOTIFICATION_SERVICE
/// <summary>
/// A service used for delivering notifications.
/// </summary>
std::shared_ptr<xbox::services::notification::NotificationService> NotificationService();
#endif

/// <summary>
/// A service for storing data in the cloud.
Expand Down Expand Up @@ -161,7 +165,7 @@ struct XblContext : public std::enable_shared_from_this<XblContext>, public xbox
std::shared_ptr<xbox::services::notification::UWPNotificationService> m_notificationService;
#elif HC_PLATFORM == HC_PLATFORM_ANDROID || HC_PLATFORM == HC_PLATFORM_IOS
std::shared_ptr<xbox::services::notification::MobileNotificationService> m_notificationService;
#else
#elif XSAPI_NOTIFICATION_SERVICE
std::shared_ptr<xbox::services::notification::NotificationService> m_notificationService;
#endif

Expand Down
5 changes: 4 additions & 1 deletion Source/Services/Leaderboard/leaderboard_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ const xsapi_internal_vector<xsapi_internal_string>& LeaderboardRow::ColumnValues
int rank = 0;
int globalRank = 0;
RETURN_HR_IF_FAILED(JsonUtils::ExtractJsonInt(json, "rank", rank, true));
RETURN_HR_IF_FAILED(JsonUtils::ExtractJsonInt(json, "globalrank", globalRank, false));
if (json.IsObject() && json.HasMember("globalrank") && !json["globalrank"].IsNull())
{
RETURN_HR_IF_FAILED(JsonUtils::ExtractJsonInt(json, "globalrank", globalRank, false));
}
xsapi_internal_vector<xsapi_internal_string> values;
if (json.IsObject() && json.HasMember("value") && !json["value"].IsNull())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
#include "pch.h"
#include "xbox_live_context_internal.h"
#include "multiplayer_activity_internal.h"
#if XSAPI_NOTIFICATION_SERVICE
#include "notification_internal.h"
#endif

using namespace xbox::services::multiplayer_activity;

#if XSAPI_NOTIFICATION_SERVICE
using namespace xbox::services::notification;
#endif

STDAPI XblMultiplayerActivityUpdateRecentPlayers(
_In_ XblContextHandle xblContextHandle,
Expand Down
Loading

0 comments on commit 851ae32

Please sign in to comment.