Skip to content

Commit

Permalink
merge changes from v1.4.6 internal repo
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMackendMS committed Apr 30, 2020
1 parent 11d722e commit 8503379
Show file tree
Hide file tree
Showing 39 changed files with 845 additions and 310 deletions.
1 change: 1 addition & 0 deletions android/ext/playfabxplatsdk/src/cppsdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.4.1)

include_directories(
${CODE_REPOSIORY_ROOT}/external/gsl/include
${CODE_REPOSIORY_ROOT}/external/playfabxplatsdk/src/cppsdk
${CODE_REPOSIORY_ROOT}/external/playfabxplatsdk/src/cppsdk/include
${CODE_REPOSIORY_ROOT}/external/playfabxplatsdk/src/cppsdk/include/curl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ namespace PlayFabInternal
{
public:
PlayFabEventAPI(); // Default constructor

// BUMBLELION: enable manual pumping of event pipeline
PlayFabEventAPI(bool threadedEventPipeline);

std::shared_ptr<IPlayFabEventRouter> GetEventRouter() const;

/// <summary>
Expand All @@ -23,9 +27,12 @@ namespace PlayFabInternal
/// - callback is a pointer to user's function to receive a notification about the outcome of the operation when the event is sent out or any error occurred.
/// </summary>
void EmitEvent(std::unique_ptr<const IPlayFabEvent> event, const PlayFabEmitEventCallback callback) const;

void EmitEvent(std::unique_ptr<const IPlayFabEvent> event, std::function<void(std::shared_ptr<const IPlayFabEvent>, std::shared_ptr<const IPlayFabEmitEventResponse>)> callback) const;

// BUMBLELION: enable manual pumping of event pipeline
void Update();

private:
std::shared_ptr<IPlayFabEventRouter> eventRouter;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace PlayFabInternal
{
public:
PlayFabEventPipelineSettings();
PlayFabEventPipelineSettings(PlayFabEventPipelineType emitType);
PlayFabEventPipelineSettings(PlayFabEventPipelineType emitType, bool useBackgroundThread);
virtual ~PlayFabEventPipelineSettings() {};

size_t bufferSize; // The minimal size of buffer, in bytes. The actually allocated size will be a power of 2 that is equal or greater than this value.
Expand All @@ -36,6 +36,9 @@ namespace PlayFabInternal
int64_t readBufferWaitTime; // The wait time between attempts to read events from buffer when it is empty, in milliseconds.
std::shared_ptr<PlayFabAuthenticationContext> authenticationContext; // The optional PlayFab authentication context that can be used with static PlayFab events API
PlayFabEventPipelineType emitType; // whether we call WriteEvent or WriteTelemetryEvent through PlayFab

// BUMBLELION: enable manual pumping of event pipeline
bool useBackgroundThread;
};

/// <summary>
Expand All @@ -46,8 +49,9 @@ namespace PlayFabInternal
public:
virtual ~IPlayFabEventPipeline() {}
virtual void Start() {} // Start pipeline's worker thread
// BUMBLELION: Added to keep the GameCore flavor from enqueuing playstream events after Cleanup is called
// BUMBLELION: needed so that we can stop the event pipeline if our token expires
virtual void Stop() = 0;
virtual void Update() = 0;
virtual void IntakeEvent(std::shared_ptr<const IPlayFabEmitEventRequest> request) = 0; // Intake an event. This method must be thread-safe.
};

Expand All @@ -67,17 +71,19 @@ namespace PlayFabInternal

std::shared_ptr<PlayFabEventPipelineSettings> GetSettings() const;
virtual void Start() override;
// BUMBLELION: Added to keep the GameCore flavor from enqueuing playstream events after Cleanup is called
// BUMBLELION: needed so that we can stop the event pipeline if our token expires
virtual void Stop() override;
virtual void Update() override;
virtual void IntakeEvent(std::shared_ptr<const IPlayFabEmitEventRequest> request) override;

void SetExceptionCallback(ExceptionCallback callback);

protected:
virtual void SendBatch(size_t& batchCounter);
virtual void SendBatch();

private:
void WorkerThread();
bool DoWork();
void WriteEventsApiCallback(const EventsModels::WriteEventsResponse& result, void* customData);
void WriteEventsApiErrorCallback(const PlayFabError& error, void* customData);
void CallbackRequest(std::shared_ptr<const IPlayFabEmitEventRequest> request, std::shared_ptr<const IPlayFabEmitEventResponse> response);
Expand All @@ -92,6 +98,8 @@ namespace PlayFabInternal
std::vector<std::shared_ptr<const IPlayFabEmitEventRequest>> batch;

private:
std::atomic_uintptr_t batchCounter;
std::chrono::steady_clock::time_point momentBatchStarted;
std::shared_ptr<PlayFabEventPipelineSettings> settings;
PlayFabEventBuffer buffer;
std::thread workerThread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace PlayFabInternal
virtual void RouteEvent(std::shared_ptr<const IPlayFabEmitEventRequest> request) const = 0; // Route an event to pipelines. This method must be thread-safe.
const std::unordered_map<EventPipelineKey, std::shared_ptr<IPlayFabEventPipeline>>& GetPipelines() const;

// BUMBLELION: enable manual pumping of event pipeline
virtual void Update() = 0;

protected:
std::unordered_map<EventPipelineKey, std::shared_ptr<IPlayFabEventPipeline>> pipelines;
};
Expand All @@ -36,8 +39,13 @@ namespace PlayFabInternal
class PlayFabEventRouter: public IPlayFabEventRouter
{
public:
PlayFabEventRouter();
virtual void RouteEvent(std::shared_ptr<const IPlayFabEmitEventRequest> request) const;
// BUMBLELION: enable manual pumping of event pipeline
PlayFabEventRouter(bool threadedEventPipeline);
virtual void RouteEvent(std::shared_ptr<const IPlayFabEmitEventRequest> request) const override;

// BUMBLELION: enable manual pumping of event pipeline
void Update() override;

private:
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
#include <ctime>
#include <chrono>

// BUMBLELION: The header we need to include depends on the platform.
#ifdef PLAYFAB_XBOX
#include <ixmlhttprequest2.h>
#else // defined(PLAYFAB_XBOX)
#include <msxml6.h>
#endif // defined(PLAYFAB_XBOX)
#include <wrl.h>

namespace PlayFabInternal
Expand Down Expand Up @@ -83,8 +88,8 @@ namespace PlayFabInternal
// ----------------------------------------------------------------------------
// Name: RequestStream
// Desc: Encapsulates a request data stream. It inherits ISequentialStream,
// which the IXMLHTTPRequest2 class uses to read from our buffer. It also
// inherits IDispatch, which the IXMLHTTPRequest2 interface on Xbox One requires
// which the IXMLHTTPRequest2 class uses to read from our buffer. It also
// inherits IDispatch, which the IXMLHTTPRequest2 interface on Xbox One requires
// (unlike on Windows, where only ISequentialStream is necessary).
// ----------------------------------------------------------------------------
class RequestStream : public Microsoft::WRL::RuntimeClass<RuntimeClassFlags<ClassicCom>, ISequentialStream, IDispatch>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// This header file is used to include headers of transport plugins supported on each platform.

#pragma once

#include <playfab/PlayFabPlatformMacros.h>

#ifdef PLAYFAB_PLATFORM_XBOX
#if defined(PLAYFAB_PLATFORM_XBOX) || defined(BUMBLELION_UWP)
#include <playfab/PlayFabIXHR2HttpPlugin.h>
#endif // PLAYFAB_PLATFORM_XBOX

#ifdef PLAYFAB_PLATFORM_WINDOWS
#if defined(PLAYFAB_PLATFORM_WINDOWS) && !defined(BUMBLELION_UWP)
#include <playfab/PlayFabWinHttpPlugin.h>
#endif // PLAYFAB_PLATFORM_WINDOWS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\playfab\PlayFabIXHR2HttpPlugin.cpp" />
<ClCompile Include="source\playfab\PlayFabIXHR2HttpRequest.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)include\jsoncpp\json\json-forwards.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)include\jsoncpp\json\json.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)include\playfab\PlayFabIXHR2HttpPlugin.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)include\playfab\PlayFabIXHR2HttpRequest.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)\include\playfab\PlayFabPlatformMacros.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)\include\playfab\PlayFabBaseModel.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)\include\playfab\PlayFabApiSettings.h" />
Expand Down Expand Up @@ -41,6 +43,8 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)source\jsoncpp\jsoncpp.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)source\playfab\PlayFabIXHR2HttpPlugin.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)source\playfab\PlayFabIXHR2HttpRequest.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)\source\playfab\PlayFabApiSettings.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)\source\playfab\PlayFabClientApi.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)\source\playfab\PlayFabAuthenticationApi.cpp" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<ProjectGuid>{81432E82-9BC5-43E1-9D6A-D06477EEE9D4}</ProjectGuid>
<RootNamespace>playfabxplatcpp_uwp</RootNamespace>
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectName>playfabxplatcpp_uwp</ProjectName>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="Shared">
<Import Project="playfabxplatcppsdk_shared.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)\UwpCommonProperties.props" />
<Import Project="PlayFabXPlatCppSdkCommonProperties.props" />
</ImportGroup>
<PropertyGroup>
<TargetName>playfabxplatcpp</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

#include <PALDefines.h>
#include <Party_c.h>
#include <gsl/span>
#include <gsl/string_span>
#include <BumblelionUuid.h>
#include <android/BumblelionJniHelper.h>

thread_local unsigned int jniAttachedCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

namespace PlayFabInternal
{
// BUMBLELION: enable manual pumping of event pipeline
// the default behavior is to use background threads to pump the event pipelines
PlayFabEventAPI::PlayFabEventAPI() :
eventRouter(std::shared_ptr<PlayFabEventRouter>(new PlayFabEventRouter())) // default event router
PlayFabEventAPI(true)
{
}

// BUMBLELION: enable manual pumping of event pipeline
PlayFabEventAPI::PlayFabEventAPI(bool threadedEventPipeline) :
eventRouter(std::make_shared<PlayFabEventRouter>(threadedEventPipeline))
{
}

Expand Down Expand Up @@ -35,6 +43,11 @@ namespace PlayFabInternal

this->eventRouter->RouteEvent(eventRequest);
}

void PlayFabEventAPI::Update()
{
this->eventRouter->Update();
}
}

#endif
Loading

0 comments on commit 8503379

Please sign in to comment.