Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.

Commit

Permalink
*fixed: SDK version to 3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zeliard committed Feb 20, 2018
1 parent 73d536d commit 809d136
Show file tree
Hide file tree
Showing 31 changed files with 7,787 additions and 2,359 deletions.
6 changes: 3 additions & 3 deletions DummyClients/DummyClients/config.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[config]

# Alias ID (when you test with GameLift Local, Set this TEST_LOCAL, and then set a gamelift endpoint at GAMELIFT_REGION)
ALIAS_ID = alias-xxxx-xxxx-xxxx-xxxx
ALIAS_ID = TEST_LOCAL

# GameLift Region (when TEST_LOCAL, for example, 127.0.0.1:9080)
GAMELIFT_REGION = ap-northeast-1
GAMELIFT_REGION = 127.0.0.1:9080

# how many game sessions(rooms)?
MAX_GAME_SESSIONS = 3
MAX_GAME_SESSIONS = 1

# each player's request sending interval (ms)
PLAYER_ACTION_INTERVAL = 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ProjectGuid>{56131AE4-9210-499E-A61C-D832AE59004F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>GameLiftGameServer</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -33,7 +34,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
Expand All @@ -46,7 +47,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
*/
#pragma once

#pragma warning(disable:4996)
#include <aws/gamelift/common/GameLift_EXPORTS.h>
#ifndef GAMELIFT_USE_STD
#include "string.h"
Expand Down Expand Up @@ -174,10 +174,10 @@ namespace GameLift
const GAMELIFT_ERROR_TYPE GetErrorType() const { return m_errorType; }

const char* GetErrorName() const { return m_errorName; }
void SetErrorName(const char* errorName) { strcpy(m_errorName, errorName); }
void SetErrorName(const char* errorName) { strncpy(m_errorName, errorName, sizeof(m_errorName)); m_errorName[sizeof(m_errorName)-1] = 0; }

const char* GetErrorMessage() const { return m_errorMessage; }
void SetErrorMessage(const char* errorMessage) { strcpy(m_errorMessage, errorMessage); }
void SetErrorMessage(const char* errorMessage) { strncpy(m_errorMessage, errorMessage, sizeof(m_errorMessage)); m_errorMessage[sizeof(m_errorMessage)-1] = 0; }

static const char* GetDefaultNameForErrorType(GAMELIFT_ERROR_TYPE errorType) {
switch (errorType) {
Expand Down Expand Up @@ -273,7 +273,10 @@ namespace GameLift
}
}

GameLiftError(){};
GameLiftError(){
memset(m_errorName, 0, sizeof(m_errorName));
memset(m_errorMessage, 0, sizeof(m_errorMessage));
};

~GameLiftError(){};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#pragma once
#include <aws/gamelift/common/GameLiftErrors.h>
#include <aws/gamelift/server/model/DescribePlayerSessionsResult.h>
#include <aws/gamelift/server/model/StartMatchBackfillResult.h>
#include <future>

namespace Aws
Expand Down Expand Up @@ -121,7 +122,9 @@ namespace Aws
typedef Outcome<void*, GameLiftError> GenericOutcome;
typedef std::future<GenericOutcome> GenericOutcomeCallable;
typedef Outcome<std::string, GameLiftError> AwsStringOutcome;
typedef Outcome<long, GameLiftError> AwsLongOutcome;
typedef Outcome<Aws::GameLift::Server::Model::DescribePlayerSessionsResult, GameLiftError> DescribePlayerSessionsOutcome;
typedef Outcome<Aws::GameLift::Server::Model::StartMatchBackfillResult, GameLiftError> StartMatchBackfillOutcome;
#else
public:

Expand Down Expand Up @@ -182,7 +185,9 @@ namespace Aws

typedef Outcome<void*, GameLiftError> GenericOutcome;
typedef Outcome<const char*, GameLiftError> AwsStringOutcome;
typedef Outcome<long, GameLiftError> AwsLongOutcome;
typedef Outcome<Aws::GameLift::Server::Model::DescribePlayerSessionsResult, GameLiftError> DescribePlayerSessionsOutcome;
typedef Outcome<Aws::GameLift::Server::Model::StartMatchBackfillResult, GameLiftError> StartMatchBackfillOutcome;
#endif
} // namespace GameLift
} // namespace Aws
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

#include <aws/gamelift/internal/GameLiftCommonState.h>
#include <aws/gamelift/server/GameLiftServerAPI.h>
#include <aws/gamelift/server/model/StartMatchBackfillRequest.h>
#include <aws/gamelift/server/model/StopMatchBackfillRequest.h>
#include <aws/gamelift/server/model/UpdateGameSession.h>
#include <aws/gamelift/internal/network/Network.h>

namespace Aws
Expand Down Expand Up @@ -42,7 +45,7 @@ namespace Internal

~GameLiftServerState();

GenericOutcome ProcessReady(const Aws::GameLift::Server::ProcessParameters &processParameters);
GenericOutcome ProcessReady(const Aws::GameLift::Server::ProcessParameters& processParameters);

GenericOutcome ProcessEnding();

Expand All @@ -56,17 +59,24 @@ namespace Internal

std::string GetGameSessionId();

long GetTerminationTime();

GenericOutcome AcceptPlayerSession(const std::string& playerSessionId);

GenericOutcome RemovePlayerSession(const std::string& playerSessionId);

DescribePlayerSessionsOutcome DescribePlayerSessions(const Aws::GameLift::Server::Model::DescribePlayerSessionsRequest &describePlayerSessionsRequest);
DescribePlayerSessionsOutcome DescribePlayerSessions(const Aws::GameLift::Server::Model::DescribePlayerSessionsRequest& describePlayerSessionsRequest);

StartMatchBackfillOutcome BackfillMatchmaking(const Aws::GameLift::Server::Model::StartMatchBackfillRequest& request);

GenericOutcome StopMatchmaking(const Aws::GameLift::Server::Model::StopMatchBackfillRequest& request);

bool IsProcessReady() { return m_processReady; }

//From Network::AuxProxyMessageHandler
void OnStartGameSession(GameSession& gameSession, sio::message::list& ack_resp) override;
void OnTerminateProcess() override;
void OnUpdateGameSession(UpdateGameSession& gameSession, sio::message::list& ack_resp) override;
void OnTerminateProcess(long terminationTime) override;

private:
bool AssertNetworkInitialized();
Expand All @@ -80,6 +90,7 @@ namespace Internal
bool DefaultHealthCheck() { return true; }

std::function<void(Aws::GameLift::Server::Model::GameSession)> m_onStartGameSession;
std::function<void(Aws::GameLift::Server::Model::UpdateGameSession)> m_onUpdateGameSession;
std::function<void()> m_onProcessTerminate;
std::function<bool()> m_onHealthCheck;

Expand All @@ -88,6 +99,8 @@ namespace Internal
//Only one game session per process.
std::string m_gameSessionId;

long m_terminationTime;

Aws::GameLift::Internal::Network::Network* m_network;
#else
public:
Expand All @@ -102,7 +115,7 @@ namespace Internal

~GameLiftServerState();

GenericOutcome ProcessReady(const Aws::GameLift::Server::ProcessParameters &processParameters);
GenericOutcome ProcessReady(const Aws::GameLift::Server::ProcessParameters& processParameters);

GenericOutcome ProcessEnding();

Expand All @@ -116,17 +129,24 @@ namespace Internal

std::string GetGameSessionId();

long GetTerminationTime();

GenericOutcome AcceptPlayerSession(const std::string& playerSessionId);

GenericOutcome RemovePlayerSession(const std::string& playerSessionId);

DescribePlayerSessionsOutcome DescribePlayerSessions(const Aws::GameLift::Server::Model::DescribePlayerSessionsRequest &describePlayerSessionsRequest);
DescribePlayerSessionsOutcome DescribePlayerSessions(const Aws::GameLift::Server::Model::DescribePlayerSessionsRequest& describePlayerSessionsRequest);

StartMatchBackfillOutcome BackfillMatchmaking(const Aws::GameLift::Server::Model::StartMatchBackfillRequest& request);

GenericOutcome StopMatchmaking(const Aws::GameLift::Server::Model::StopMatchBackfillRequest& request);

bool IsProcessReady() { return m_processReady; }

//From Network::AuxProxyMessageHandler
void OnStartGameSession(GameSession& gameSession, sio::message::list& ack_resp) override;
void OnTerminateProcess() override;
void OnUpdateGameSession(UpdateGameSession& gameSession, sio::message::list& ack_resp) override;
void OnTerminateProcess(long terminationTime) override;

private:
bool AssertNetworkInitialized();
Expand All @@ -140,10 +160,12 @@ namespace Internal
bool DefaultHealthCheck() { return true; }

std::function<void(Aws::GameLift::Server::Model::GameSession, void*)> m_onStartGameSession;
std::function<void(Aws::GameLift::Server::Model::UpdateGameSession, void*)> m_onUpdateGameSession;
std::function<void(void*)> m_onProcessTerminate;
std::function<bool(void*)> m_onHealthCheck;

void* m_startGameSessionState;
void* m_updateGameSessionState;
void* m_processTerminateState;
void* m_healthCheckState;

Expand All @@ -156,6 +178,8 @@ namespace Internal
//Only one game session per process.
std::string m_gameSessionId;

long m_terminationTime;

Aws::GameLift::Internal::Network::Network* m_network;
#endif
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <aws/gamelift/server/model/AttributeValue.h>
#include <aws/gamelift/server/protocols/sdk.pb.h>

namespace Aws
{
namespace GameLift
{
namespace Internal
{
namespace ModelMapper
{
using namespace Aws::GameLift::Server::Model;
using namespace com::amazon::whitewater::auxproxy;

class AttributeValueMapper
{
public:
#ifdef GAMELIFT_USE_STD
static pbuffer::AttributeValue ParseFromAttributeValue(const AttributeValue &attrValue)
{
AttributeValue::AttrType type = attrValue.GetType();
pbuffer::AttributeValue event;
event.set_type(static_cast<int>(type));

switch (type)
{
case AttributeValue::AttrType::STRING:
{
event.set_s(attrValue.GetS());
break;
}

case AttributeValue::AttrType::STRING_LIST:
{
for (auto& str : attrValue.GetSL())
{
event.add_sl(str);
}
break;
}

case AttributeValue::AttrType::STRING_DOUBLE_MAP:
{
for (const auto& iter : attrValue.GetSDM())
{
(*event.mutable_sdm())[iter.first] = iter.second;
}
break;
}

default:
{
event.set_n(attrValue.GetN());
break;
}
}

return event;
}
#else
static pbuffer::AttributeValue ParseFromAttributeValue(const AttributeValue &attrValue)
{
AttributeValue::AttrType type = attrValue.GetType();
pbuffer::AttributeValue event;
event.set_type(static_cast<int>(type));

switch (type)
{
case AttributeValue::AttrType::STRING:
{
event.set_s(attrValue.GetS());
break;
}

case AttributeValue::AttrType::STRING_LIST:
{
int count;
const AttributeValue::AttributeStringType* strs = attrValue.GetSL(count);
for (int index = 0; index < count; ++index)
{
event.add_sl(strs[index]);
}
break;
}

case AttributeValue::AttrType::STRING_DOUBLE_MAP:
{
int count;
const AttributeValue::KeyAndValue* entries = attrValue.GetSDM(count);
for (int index = 0; index < count; ++index)
{
(*event.mutable_sdm())[entries[index].GetKey()] = entries[index].GetValue();
}
break;
}

default:
{
event.set_n(attrValue.GetN());
break;
}
}

return event;
}
#endif
};
} //namespace ModelMapper
} //namespace Internal
} //namespace GameLift
} //namespace Aws
Loading

0 comments on commit 809d136

Please sign in to comment.