476 lines
14 KiB
C++
476 lines
14 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#pragma once
|
|
#include "ubiservices/core/configs/config.h"
|
|
#include "ubiservices/core/configs/environment.h"
|
|
#include "ubiservices/core/tasks/asyncResult.h"
|
|
#include "ubiservices/core/types/containers.h"
|
|
#if !defined(US_SDK_SERVER)
|
|
#include "ubiservices/services/event/eventsParams.h"
|
|
#include "ubiservices/services/populations/dynamicPopulationCustomParams.h"
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
#include "ubiservices/services/primaryStore/win32/primaryStoreParams.h"
|
|
#endif
|
|
#endif
|
|
|
|
namespace US_NS {;
|
|
|
|
// Forward declarations
|
|
class Facade;
|
|
class CriticalSection;
|
|
#if defined(US_MODULE_APPLICATION)
|
|
class ApplicationClient;
|
|
#endif
|
|
class AuthenticationClient;
|
|
#if defined(US_MODULE_BATTLEPASS)
|
|
class BattlepassClient;
|
|
#endif
|
|
#if defined(US_MODULE_BLOCKLIST)
|
|
class BlocklistClient;
|
|
#endif
|
|
class ChallengeClient;
|
|
#if defined(US_MODULE_CLUB)
|
|
class ClubClient;
|
|
#endif
|
|
class ConnectionClient;
|
|
#if defined(US_MODULE_ENTITY)
|
|
class EntityClient;
|
|
#endif
|
|
class EventClient;
|
|
#if defined(US_MODULE_FRIEND)
|
|
class FriendClient;
|
|
#endif
|
|
#if defined(US_MODULE_GAMESPLAYED)
|
|
class GamesPlayedClient;
|
|
#endif
|
|
class HttpClient;
|
|
class HttpHeader;
|
|
#if defined(US_MODULE_LEADERBOARD)
|
|
class LeaderboardClient;
|
|
#endif
|
|
#if defined(US_MODULE_LOCALIZATION)
|
|
class LocalizationClient;
|
|
#endif
|
|
#if defined(US_MODULE_MATCHMAKING)
|
|
class MatchmakingClient;
|
|
#endif
|
|
class ModerationClient;
|
|
#if defined(US_MODULE_NEWS)
|
|
class NewsClient;
|
|
#endif
|
|
class NotificationClient;
|
|
class OverlayClient;
|
|
class ParametersClient;
|
|
#if defined(US_MODULE_PERSONA)
|
|
class PersonaClient;
|
|
#endif
|
|
#if defined(US_MODULE_PLAYER_ONLINE_STATUS)
|
|
class PlayerOnlineStatusClient;
|
|
#endif
|
|
#if defined(US_MODULE_PLAYERREPORTS)
|
|
class PlayerReportsClient;
|
|
#endif
|
|
#if defined(US_PRIMARY_STORE_ENABLED) || defined(US_PRIMARY_STORE_MOBILE_ENABLED)
|
|
class PrimaryStoreClient;
|
|
#endif
|
|
class PopulationClient;
|
|
#if defined(US_MODULE_PROFILE)
|
|
class ProfileClient;
|
|
#endif
|
|
#if defined(US_MODULE_RECOMMENDATIONS)
|
|
class RecommendationsClient;
|
|
#endif
|
|
class RemoteLogClient;
|
|
class RemoteLoggerSdk;
|
|
class RemoteLoggerCustom;
|
|
class SecondaryStoreClient;
|
|
#if defined(US_MODULE_SSI)
|
|
class SecondaryStoreInstantiationClient;
|
|
#endif
|
|
class SessionManager;
|
|
#if defined(US_MODULE_STATS)
|
|
class StatsClient;
|
|
#endif
|
|
#if defined(US_MODULE_TLOG) && defined(US_TARGET_WINDOWS)
|
|
class TLogClient;
|
|
#endif
|
|
#if defined(US_ENABLE_UPLAY)
|
|
class UplayClient;
|
|
#endif
|
|
#if defined(US_MODULE_USER)
|
|
class UserClient;
|
|
#endif
|
|
#if defined(US_MODULE_UGC)
|
|
class UserGeneratedContentsClient;
|
|
#endif
|
|
#if defined(US_MODULE_VOICECHAT)
|
|
class VoicechatClient;
|
|
#endif
|
|
class WebSocketClient;
|
|
#if !defined(US_SDK_SERVER)
|
|
class PlayerCredentialsBase;
|
|
#endif
|
|
|
|
// Defines the real facade to access all features for one specific player.
|
|
// The FacadeInternal life is manage by the SDK via a SmartPtr.
|
|
// If the game deletes the Facade instance while jobs are launching at the same time (returning from suspended)
|
|
// the FacadeInternal stays alive up to the completion of all launched jobs.
|
|
class FacadeInternal final : public RefCountedObject
|
|
{
|
|
public:
|
|
FacadeInternal();
|
|
~FacadeInternal();
|
|
|
|
void init(Facade* owner);
|
|
|
|
#if defined(US_SDK_SERVER)
|
|
AsyncResult<Empty> createSession(const String& secret, const Vector<String>& parametersGroupApplication,
|
|
const Vector<String>& parametersGroupSpace);
|
|
#else
|
|
AsyncResult<Empty> createSession(const PlayerCredentialsBase& credentials,
|
|
const Vector<String>& parametersGroupApplication,
|
|
const Vector<String>& parametersGroupSpace,
|
|
const EventsParams& eventsParams = EventsParams()
|
|
, const String& connectionMetaData = String()
|
|
, const DynamicPopulationCustomParams& populationParams = DynamicPopulationCustomParams()
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
, const PrimaryStoreParams& primaryStoreParams = PrimaryStoreParams()
|
|
#endif
|
|
);
|
|
#endif
|
|
|
|
AsyncResult<Empty> deleteSession();
|
|
|
|
const Environment getDetectedEnvironment() const;
|
|
|
|
const SessionManager& getManager() const;
|
|
SessionManager& getManager();
|
|
|
|
const RemoteLoggerCustom& getRemoteLoggerCustom() const;
|
|
RemoteLoggerCustom& getRemoteLoggerCustom();
|
|
|
|
const RemoteLoggerSdk& getRemoteLoggerSdk() const;
|
|
RemoteLoggerSdk& getRemoteLoggerSdk();
|
|
|
|
|
|
/// Client accessors - All flavors (including modules)
|
|
#if defined(US_MODULE_APPLICATION)
|
|
const ApplicationClient& getApplicationClient() const;
|
|
ApplicationClient& getApplicationClient();
|
|
#endif
|
|
|
|
const AuthenticationClient& getAuthenticationClient() const;
|
|
AuthenticationClient& getAuthenticationClient();
|
|
|
|
#if defined(US_MODULE_BATTLEPASS)
|
|
const BattlepassClient& getBattlepassClient() const;
|
|
BattlepassClient& getBattlepassClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_BLOCKLIST)
|
|
const BlocklistClient& getBlocklistClient() const;
|
|
BlocklistClient& getBlocklistClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_CHALLENGE)
|
|
const ChallengeClient& getChallengeClient() const;
|
|
ChallengeClient& getChallengeClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_CLUB)
|
|
ClubClient& getClubClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_ENTITY)
|
|
EntityClient& getEntityClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_FRIEND)
|
|
FriendClient& getFriendClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_GAMESPLAYED)
|
|
GamesPlayedClient& getGamesPlayedClient();
|
|
#endif
|
|
|
|
const EventClient& getEventClient() const;
|
|
EventClient& getEventClient();
|
|
|
|
HttpClient& getHttpClient();
|
|
|
|
#if defined(US_MODULE_LEADERBOARD)
|
|
LeaderboardClient& getLeaderboardClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_LOCALIZATION)
|
|
LocalizationClient& getLocalizationClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_MATCHMAKING)
|
|
const MatchmakingClient& getMatchmakingClient() const;
|
|
MatchmakingClient& getMatchmakingClient();
|
|
#endif // defined(US_MODULE_MATCHMAKING)
|
|
|
|
#if defined(US_MODULE_MODERATION)
|
|
const ModerationClient& getModerationClient() const;
|
|
ModerationClient& getModerationClient();
|
|
#endif // defined(US_MODULE_MODERATION)
|
|
|
|
#if defined(US_MODULE_NEWS)
|
|
NewsClient& getNewsClient();
|
|
#endif
|
|
|
|
const ParametersClient& getParametersClient() const;
|
|
ParametersClient& getParametersClient();
|
|
#if defined(US_MODULE_PERSONA)
|
|
const PersonaClient& getPersonaClient() const;
|
|
PersonaClient& getPersonaClient();
|
|
#endif
|
|
#if defined(US_MODULE_PLAYER_ONLINE_STATUS)
|
|
const PlayerOnlineStatusClient& getPlayerOnlineStatusClient() const;
|
|
PlayerOnlineStatusClient& getPlayerOnlineStatusClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_PLAYERREPORTS)
|
|
const PlayerReportsClient& getPlayerReportsClient() const;
|
|
PlayerReportsClient& getPlayerReportsClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_PROFILE)
|
|
const ProfileClient& getProfileClient() const;
|
|
ProfileClient& getProfileClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_STATS)
|
|
StatsClient& getStatsClient();
|
|
#endif
|
|
|
|
#if defined(US_PRIMARY_STORE_ENABLED) || defined(US_PRIMARY_STORE_MOBILE_ENABLED)
|
|
PrimaryStoreClient& getPrimaryStoreClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_RECOMMENDATIONS)
|
|
const RecommendationsClient& getRecommendationsClient() const;
|
|
RecommendationsClient& getRecommendationsClient();
|
|
#endif
|
|
|
|
RemoteLogClient& getRemoteLogClient();
|
|
|
|
#if defined(US_MODULE_SSI)
|
|
SecondaryStoreInstantiationClient& getSecondaryStoreInstantiationClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_STORE)
|
|
SecondaryStoreClient& getSecondaryStoreClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_TLOG) && defined(US_TARGET_WINDOWS)
|
|
TLogClient& getTLogClient();
|
|
#endif
|
|
|
|
#if defined(US_ENABLE_UPLAY)
|
|
UplayClient& getUplayClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_UGC)
|
|
const UserGeneratedContentsClient& getUserGeneratedContentsClient() const;
|
|
UserGeneratedContentsClient& getUserGeneratedContentsClient();
|
|
#endif // US_MODULE_UGC
|
|
|
|
#if defined(US_MODULE_USER)
|
|
UserClient& getUserClient();
|
|
#endif
|
|
|
|
#if defined(US_MODULE_VOICECHAT)
|
|
VoicechatClient& getVoicechatClient();
|
|
#endif
|
|
|
|
/// Client accessors - SDK FULL (Should be emptied when all modules will be configurable)
|
|
#if defined(US_TARGET_STADIA)
|
|
|
|
OverlayClient& getOverlayClient();
|
|
|
|
#endif // defined(US_TARGET_STADIA)
|
|
|
|
/// Client accessors - Client that shouldn't be in Server SDK
|
|
#if !defined(US_SDK_SERVER)
|
|
ConnectionClient& getConnectionClient();
|
|
|
|
NotificationClient& getNotificationClient();
|
|
|
|
const PopulationClient& getPopulationsClient() const;
|
|
PopulationClient& getPopulationsClient();
|
|
|
|
WebSocketClient& getWebsocketClient();
|
|
#endif // !defined(US_SDK_SERVER)
|
|
|
|
private:
|
|
//US_CLASS_COPY_NOT_ALLOWED(FacadeInternal);
|
|
|
|
friend class FacadesManager; // Needed to call invalidate
|
|
friend class FacadeInternalTestHelper;
|
|
|
|
void stopFacade();
|
|
|
|
// Immediately terminates all pending jobs by deleting all clients.
|
|
// Once this method is called, all references to clients are indeed invalid
|
|
// and must not be used anymore. There is no way to recover from the
|
|
// invalidate state. The facade must be destroyed.
|
|
void invalidate();
|
|
|
|
void deleteMembers();
|
|
|
|
::std::unique_ptr<CriticalSection> m_criticalSection;
|
|
|
|
template<class _TClientType>
|
|
_TClientType& getClient(::std::unique_ptr<_TClientType>& member);
|
|
|
|
friend class FacadeMock;
|
|
|
|
bool m_valid;
|
|
|
|
::std::unique_ptr<SessionManager> m_sessionManager;
|
|
|
|
::std::unique_ptr<RemoteLoggerSdk> m_remoteLoggerSdk;
|
|
::std::unique_ptr<RemoteLoggerCustom> m_remoteLoggerCustom;
|
|
|
|
// We keep a ptr to the Facade (the owner)
|
|
// The resume from background job has to return Facade(s)
|
|
// so we use this pointer.
|
|
//
|
|
// <<< Attention >>>
|
|
// Never use this pointer internally because prod could delete
|
|
// the Facade and this pointer would not be valid
|
|
friend class Facade;
|
|
friend class JobResumeFromSuspended;
|
|
friend class JobResumeFocusMaster;
|
|
Facade* m_owner;
|
|
|
|
/// Client - All flavors (including modules)
|
|
#if defined(US_MODULE_APPLICATION)
|
|
::std::unique_ptr<ApplicationClient> m_applicationClient;
|
|
#endif
|
|
::std::unique_ptr<AuthenticationClient> m_authenticationClient;
|
|
#if defined(US_MODULE_BATTLEPASS)
|
|
::std::unique_ptr<BattlepassClient> m_battlepassClient;
|
|
#endif
|
|
#if defined(US_MODULE_BLOCKLIST)
|
|
::std::unique_ptr<BlocklistClient> m_blocklistClient;
|
|
#endif
|
|
#if defined(US_MODULE_CHALLENGE)
|
|
::std::unique_ptr<ChallengeClient> m_challengeClient;
|
|
#endif
|
|
#if defined(US_MODULE_CLUB)
|
|
::std::unique_ptr<ClubClient> m_clubClient;
|
|
#endif
|
|
#if defined(US_MODULE_ENTITY)
|
|
::std::unique_ptr<EntityClient> m_entityClient;
|
|
#endif
|
|
#if defined(US_MODULE_FRIEND)
|
|
::std::unique_ptr<FriendClient> m_friendClient;
|
|
#endif
|
|
#if defined(US_MODULE_GAMESPLAYED)
|
|
::std::unique_ptr<GamesPlayedClient> m_gamesPlayedClient;
|
|
#endif
|
|
::std::unique_ptr<EventClient> m_eventClient;
|
|
::std::unique_ptr<HttpClient> m_httpClient;
|
|
#if defined(US_MODULE_LEADERBOARD)
|
|
::std::unique_ptr<LeaderboardClient> m_leaderboardClient;
|
|
#endif
|
|
#if defined(US_MODULE_LOCALIZATION)
|
|
::std::unique_ptr<LocalizationClient> m_localizationClient;
|
|
#endif
|
|
#if defined(US_MODULE_MATCHMAKING)
|
|
::std::unique_ptr<MatchmakingClient> m_matchmakingClient;
|
|
#endif
|
|
#if defined(US_MODULE_MODERATION)
|
|
::std::unique_ptr<ModerationClient> m_moderationClient;
|
|
#endif
|
|
#if defined(US_MODULE_NEWS)
|
|
::std::unique_ptr<NewsClient> m_newsClient;
|
|
#endif
|
|
#if defined(US_MODULE_PERSONA)
|
|
::std::unique_ptr<PersonaClient> m_personaClient;
|
|
#endif
|
|
#if defined(US_MODULE_PLAYER_ONLINE_STATUS)
|
|
::std::unique_ptr<PlayerOnlineStatusClient> m_playerOnlineStatusClient;
|
|
#endif
|
|
#if defined(US_MODULE_PLAYERREPORTS)
|
|
::std::unique_ptr<PlayerReportsClient> m_playerReportsClient;
|
|
#endif
|
|
#if defined(US_MODULE_PROFILE)
|
|
::std::unique_ptr<ProfileClient> m_profileClient;
|
|
#endif
|
|
#if defined(US_MODULE_STATS)
|
|
::std::unique_ptr<StatsClient> m_statsClient;
|
|
#endif
|
|
::std::unique_ptr<ParametersClient> m_parametersClient;
|
|
#if defined(US_PRIMARY_STORE_ENABLED) || defined(US_PRIMARY_STORE_MOBILE_ENABLED)
|
|
::std::unique_ptr<PrimaryStoreClient> m_primaryStoreClient;
|
|
#endif
|
|
::std::unique_ptr<RemoteLogClient> m_remoteLogClient;
|
|
#if defined(US_MODULE_RECOMMENDATIONS)
|
|
::std::unique_ptr<RecommendationsClient> m_recommendationsClient;
|
|
#endif
|
|
#if defined(US_MODULE_SSI)
|
|
::std::unique_ptr<SecondaryStoreInstantiationClient> m_secondaryStoreInstantiationClient;
|
|
#endif
|
|
#if defined(US_MODULE_STORE)
|
|
::std::unique_ptr<SecondaryStoreClient> m_secondaryStoreClient;
|
|
#endif
|
|
#if defined(US_MODULE_TLOG) && defined(US_TARGET_WINDOWS)
|
|
::std::unique_ptr<TLogClient> m_tLogClient;
|
|
#endif
|
|
#if defined(US_ENABLE_UPLAY)
|
|
::std::unique_ptr<UplayClient> m_uplayClient;
|
|
#endif
|
|
#if defined(US_MODULE_UGC)
|
|
::std::unique_ptr<UserGeneratedContentsClient> m_userGeneratedContentsClient;
|
|
#endif
|
|
#if defined(US_MODULE_USER)
|
|
::std::unique_ptr<UserClient> m_userClient;
|
|
#endif
|
|
#if defined(US_MODULE_VOICECHAT)
|
|
::std::unique_ptr<VoicechatClient> m_voicechatClient;
|
|
#endif
|
|
|
|
#if defined(US_TARGET_STADIA)
|
|
::std::unique_ptr<OverlayClient> m_overlayClient;
|
|
#endif // defined(US_TARGET_STADIA)
|
|
|
|
/// Client accessors - Client that shouldn't be in Server SDK
|
|
#if !defined(US_SDK_SERVER)
|
|
::std::unique_ptr<ConnectionClient> m_connectionClient;
|
|
::std::unique_ptr<NotificationClient> m_notificationClient;
|
|
::std::unique_ptr<PopulationClient> m_populationsClient;
|
|
::std::unique_ptr<WebSocketClient> m_websocketClient;
|
|
#endif
|
|
};
|
|
|
|
class TestRemoteLogClientHelper // For test purposes ONLY
|
|
{
|
|
public:
|
|
static RemoteLoggerCustom& getRemoteLoggerCustom(FacadeInternal& facade);
|
|
};
|
|
|
|
struct TestExtendSessionHelper // For test purposes ONLY
|
|
{
|
|
US_FRIEND_TEST(EXTEND_SESSION, US_ExtendSession);
|
|
US_FRIEND_TEST(USTK_NOLOGIN_NOSCHEDULER, USNOT_ExerciseRenewTicket);
|
|
US_FRIEND_TEST(USTK_NOLOGIN_NOSCHEDULER, DISABLED_FLAKY_USNOT_ExerciseRenewTicket);
|
|
static void reduceSessionDuration(Facade& facade, uint64 expirationTimeMs);
|
|
};
|
|
|
|
#if !defined(US_SDK_SERVER)
|
|
class TestSuspendedModeHelper // For test purposes ONLY
|
|
{
|
|
public:
|
|
static int32 getRefCount(const Facade& facade);
|
|
static int32 getRefCount(const FacadeInternal& facade);
|
|
static void copyRef(SmartPtr<FacadeInternal>& target, const Facade& source);
|
|
static const HttpHeader& getRemoteLoggerSdkHeaders(FacadeInternal& facade);
|
|
};
|
|
|
|
#endif
|
|
};
|