C++용 Amazon GameLift 서버 SDK 5.x: 작업
Amazon GameLift C++ 서버 SDK 5.x 참조를 사용하면 Amazon GameLift와 함께 사용할 멀티플레이어 게임을 통합하는 데 도움이 됩니다. 통합 프로세스에 대한 지침은 Amazon GameLift를 게임 서버에 추가 페이지를 참조하세요.
참고
이 주제에서는 C++ Standard Library(std
)으로 빌드할 때 사용할 수 있는 Amazon GameLift C++ API에 대해 설명합니다. 특히, 이 설명서는 -DDGAMELIFT_USE_STD=1
옵션을 사용하여 컴파일하는 코드에 적용됩니다.
C++용 Amazon GameLift 서버 SDK 5.x: 데이터 유형
주제
- GetSdkVersion()
- InitSDK()
- InitSDK()
- ProcessReady()
- ProcessReadyAsync()
- ProcessEnding()
- ActivateGameSession()
- UpdatePlayerSessionCreationPolicy()
- GetGameSessionId()
- GetTerminationTime()
- AcceptPlayerSession()
- RemovePlayerSession()
- DescribePlayerSessions()
- StartMatchBackfill()
- StopMatchBackfill()
- GetComputeCertificate()
- GetFleetRoleCredentials()
- Destroy()
GetSdkVersion()
현재 서버 프로세스에 빌드된 SDK 버전 번호를 반환합니다.
구문
Aws::GameLift::AwsStringOutcome Server::GetSdkVersion();
반환 값
성공하면 현재 SDK 버전을 AwsStringOutcome 객체로 반환합니다. 반환된 객체는 버전 번호(예: 5.0.0
)를 포함합니다. 실패하면 오류 메시지를 반환합니다.
예
Aws::GameLift::AwsStringOutcome SdkVersionOutcome = Aws::GameLift::Server::GetSdkVersion();
InitSDK()
Amazon GameLift SDK를 초기화합니다. Amazon GameLift와 관련된 다른 초기화 단계가 발생하기 전에 출시 시점에서 이 메서드를 호출합니다. 이 작업은 호스트 환경에서 서버 파라미터를 읽어 게임 서버 프로세스와 Amazon GameLift 서비스 간의 통신을 설정합니다.
Amazon GameLift 에이전트 없이 게임 서버 빌드가 Anywhere 플릿 또는 컨테이너 플릿에 배포되는 경우에 InitSDK()를 호출하고 서버 파라미터 세트를 지정합니다.
구문
Server::InitSDKOutcome Server::initSdkOutcome = InitSDK();
반환 값
서버 프로세스가 ProcessReady()를 호출할 준비가 되었는지 여부를 나타내는 InitSDKOutcome 객체를 반환합니다.
예
//Call InitSDK to establish a local connection with the GameLift agent to enable further communication. Aws::GameLift::Server::InitSDKOutcome initSdkOutcome = Aws::GameLift::Server::InitSDK();
InitSDK()
Amazon GameLift SDK를 초기화합니다. Amazon GameLift와 관련된 다른 초기화 단계가 발생하기 전에 출시 시점에서 이 메서드를 호출합니다. 이 작업에는 게임 서버 프로세스와 Amazon GameLift 서비스 간의 통신을 설정하기 위한 서버 파라미터 세트가 요구됩니다.
게임 서버 빌드가 Amazon GameLift 관리형 EC2 플릿 또는 Amazon GameLift 에이전트를 사용하는 Amazon GameLift Anywhere 플릿 또는 컨테이너 플릿에 배포되는 경우 서버 파라미터 없이 InitSDK()를 호출합니다.
구문
Server::InitSDKOutcome Server::initSdkOutcome = InitSDK(serverParameters);
파라미터
- ServerParameters
-
Amazon GameLift Anywhere 플릿에서 게임 서버를 초기화하려면 다음 정보를 사용하여
ServerParameters
객체를 구성합니다.-
게임 서버에 연결하는 데 사용되는 WebSocket의 URL입니다.
-
게임 서버를 호스팅하는 데 사용되는 프로세스의 ID입니다.
-
게임 서버 프로세스를 호스팅하는 컴퓨팅의 ID입니다.
-
Amazon GameLift Anywhere 컴퓨팅을 포함하는 Amazon GameLift 플릿의 ID입니다.
-
Amazon GameLift 작업을 통해 생성된 인증 토큰입니다.
-
반환 값
서버 프로세스가 ProcessReady()를 호출할 준비가 되었는지 여부를 나타내는 InitSDKOutcome 객체를 반환합니다.
참고
Anywhere 플릿에 배포된 게임 빌드에 대한 InitSDK()
로의 호출이 실패하는 경우 빌드 리소스를 생성할 때 사용된 ServerSdkVersion
파라미터를 확인합니다. 명시적으로 이 값을 사용 중인 Server SDK 버전으로 설정해야 합니다. 이 파라미터의 기본값은 4.x이며 호환되지 않습니다. 이 문제를 해결하려면 새 빌드를 생성하여 새 플릿에 배포해야 합니다.
예
Amazon GameLift Anywhere 예제
//Define the server parameters std::string websocketUrl = "
wss://us-west-1.api.amazongamelift.com
"; std::string processId = "PID1234
"; std::string fleetId = "arn:aws:gamelift:us-west-1:111122223333:fleet/fleet-9999ffff-88ee-77dd-66cc-5555bbbb44aa
"; std::string hostId = "HardwareAnywhere
"; std::string authToken = "1111aaaa-22bb-33cc-44dd-5555eeee66ff
"; Aws::GameLift::Server::Model::ServerParameters serverParameters = Aws::GameLift::Server::Model::ServerParameters(webSocketUrl, authToken, fleetId, hostId, processId); //Call InitSDK to establish a local connection with the GameLift agent to enable further communication. Aws::GameLift::Server::InitSDKOutcome initSdkOutcome = Aws::GameLift::Server::InitSDK(serverParameters);
ProcessReady()
Amazon GameLift에 서버 프로세스가 게임 세션을 호스팅할 준비가 되었음을 알립니다. InitSDK() 호출 후 이 메서드를 호출합니다. 이 메서드는 프로세스당 한 번만 호출해야 합니다.
구문
GenericOutcome ProcessReady(const Aws::GameLift::Server::ProcessParameters
&processParameters);
파라미터
- processParameters
-
다음 서버 프로세스 관련 정보를 전달하는 ProcessParameters 객체입니다.
-
게임 서버 코드에 구현되어 있는 콜백 메서드의 이름으로, 서버 프로세스와 통신할 수 있도록 Amazon GameLift 서비스가 호출하는 메서드입니다.
-
서버 프로세스가 수신하는 포트 번호입니다.
-
Amazon GameLift가 캡처 및 저장하도록 하려는 모든 게임 세션별 파일에 대한 경로입니다.
-
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
이 예에서는 ProcessReady() 호출 및 위임 함수 구현을 모두 보여줍니다.
// Set parameters and call ProcessReady std::string serverLog("
serverOut.log
"); // Example of a log file written by the game server std::vector<std::string> logPaths; logPaths.push_back(serverLog); int listenPort =9339
; Aws::GameLift::Server::ProcessParameters processReadyParameter = Aws::GameLift::Server::ProcessParameters( std::bind(&Server::onStartGameSession, this, std::placeholders::_1), std::bind(&Server::onProcessTerminate, this), std::bind(&Server::OnHealthCheck, this), std::bind(&Server::OnUpdateGameSession, this), listenPort, Aws::GameLift::Server::LogParameters(logPaths) ); Aws::GameLift::GenericOutcome outcome = Aws::GameLift::Server::ProcessReady(processReadyParameter); // Implement callback functions void Server::onStartGameSession(Aws::GameLift::Model::GameSession myGameSession) { // game-specific tasks when starting a new game session, such as loading map GenericOutcome outcome = Aws::GameLift::Server::ActivateGameSession (maxPlayers); } void Server::onProcessTerminate() { // game-specific tasks required to gracefully shut down a game session, // such as notifying players, preserving game state data, and other cleanup GenericOutcome outcome = Aws::GameLift::Server::ProcessEnding(); } bool Server::onHealthCheck() { bool health; // complete health evaluation within 60 seconds and set health return health; }
ProcessReadyAsync()
Amazon GameLift 서비스에 서버 프로세스가 게임 세션을 호스팅할 준비가 되었음을 알립니다. 이 메서드는 서버 프로세스가 게임 세션을 호스팅할 준비가 된 후 호출되어야 합니다. 이 파라미터는 특정 상황에서 호출할 Amazon GameLift 콜백 함수의 이름을 지정합니다. 게임 서버 코드는 이 함수를 구현해야 합니다.
이 호출은 비동기식입니다. 동기식 호출을 수행하려면 ProcessReady()를 사용합니다. 자세한 내용은 서버 프로세스 초기화 섹션을 참조하세요.
구문
GenericOutcomeCallable ProcessReadyAsync( const Aws::GameLift::Server::ProcessParameters &processParameters);
파라미터
- processParameters
-
다음 서버 프로세스 관련 정보를 전달하는 ProcessParameters 객체입니다.
-
게임 서버 코드에 구현되어 있는 콜백 메서드의 이름으로, 서버 프로세스와 통신할 수 있도록 Amazon GameLift 서비스가 호출하는 메서드입니다.
-
서버 프로세스가 수신하는 포트 번호입니다.
-
Amazon GameLift가 캡처 및 저장하도록 하려는 모든 게임 세션별 파일에 대한 경로입니다.
필수 여부: 예
-
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
// Set parameters and call ProcessReady std::string serverLog("
serverOut.log
"); // This is an example of a log file written by the game server std::vector<std::string> logPaths; logPaths.push_back(serverLog); int listenPort =9339
; Aws::GameLift::Server::ProcessParameters processReadyParameter = Aws::GameLift::Server::ProcessParameters(std::bind(&Server::onStartGameSession, this, std::placeholders::_1), std::bind(&Server::onProcessTerminate, this), std::bind(&Server::OnHealthCheck, this), std::bind(&Server::OnUpdateGameSession, this), listenPort, Aws::GameLift::Server::LogParameters(logPaths)); Aws::GameLift::GenericOutcomeCallable outcome = Aws::GameLift::Server::ProcessReadyAsync(processReadyParameter); // Implement callback functions void onStartGameSession(Aws::GameLift::Model::GameSession myGameSession) { // game-specific tasks when starting a new game session, such as loading map GenericOutcome outcome = Aws::GameLift::Server::ActivateGameSession (maxPlayers); } void onProcessTerminate() { // game-specific tasks required to gracefully shut down a game session, // such as notifying players, preserving game state data, and other cleanup GenericOutcome outcome = Aws::GameLift::Server::ProcessEnding(); } bool onHealthCheck() { // perform health evaluation and complete within 60 seconds return health; }
ProcessEnding()
서버 프로세스가 종료 중임을 Amazon GameLift에 알립니다. 활성 게임 세션의 종료 등 다른 모든 정리 작업 이후 및 프로세스를 종료하기 전에 이 메서드를 호출합니다. ProcessEnding()
의 결과에 따라 프로세스가 성공(0) 또는 오류(-1)로 종료되고 플릿 이벤트가 생성됩니다. 오류가 발생하여 프로세스가 종료되는 경우 생성되는 플릿 이벤트는 SERVER_PROCESS_TERMINATED_UNHEALTHY
입니다.
구문
Aws::GameLift::GenericOutcome processEndingOutcome = Aws::GameLift::Server::ProcessEnding();
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
이 예제에서는 성공 또는 오류 발생 시 서버 프로세스를 종료하기 전에 ProcessEnding()
및 Destroy()
를 호출합니다.
Aws::GameLift::GenericOutcome processEndingOutcome = Aws::GameLift::Server::ProcessEnding(); Aws::GameLift::Server::Destroy(); // Exit the process with success or failure if (processEndingOutcome.IsSuccess()) { exit(0); } else { cout << "ProcessEnding() failed. Error: " << processEndingOutcome.GetError().GetErrorMessage(); exit(-1); }
ActivateGameSession()
Amazon GameLift에 서버 프로세스가 게임 세션을 활성화했으며 이제 플레이어 연결을 수신할 준비가 되었음을 알립니다. 이 작업은 모든 게임 세션 초기화 후 onStartGameSession()
콜백 함수의 일부로 호출되어야 합니다.
구문
Aws::GameLift::GenericOutcome activateGameSessionOutcome = Aws::GameLift::Server::ActivateGameSession();
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
이 예에서는 onStartGameSession()
위임 함수의 일부로 ActivateGameSession()
이 호출되는 것을 보여줍니다.
void onStartGameSession(Aws::GameLift::Model::GameSession myGameSession) { // game-specific tasks when starting a new game session, such as loading map GenericOutcome outcome = Aws::GameLift::Server::ActivateGameSession(); }
UpdatePlayerSessionCreationPolicy()
현재 게임 세션의 새 플레이어 세션 수락 가능성을 업데이트합니다. 모든 새 플레이어 세션을 수락하거나 거부하도록 게임 세션을 설정할 수 있습니다.
구문
GenericOutcome UpdatePlayerSessionCreationPolicy(Aws::GameLift::Model::PlayerSessionCreationPolicy newPlayerSessionPolicy);
파라미터
- playerCreationSessionPolicy
-
형식:
PlayerSessionCreationPolicy
열거형 값.필수 여부: 예
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
이 예는 모든 플레이어를 수락하도록 현재 게임 세션의 참여 정책을 설정합니다.
Aws::GameLift::GenericOutcome outcome = Aws::GameLift::Server::UpdatePlayerSessionCreationPolicy(Aws::GameLift::Model::PlayerSessionCreationPolicy::
ACCEPT_ALL
);
GetGameSessionId()
활성 서버 프로세스가 호스팅된 게임 세션의 ID를 가져옵니다.
게임 세션으로 활성화되지 않은 유휴 프로세스의 경우 호출은 GameLiftError를 반환합니다.
구문
AwsStringOutcome GetGameSessionId()
파라미터
이 작업에는 파라미터가 없습니다.
반환 값
성공하면 게임 세션 ID를 AwsStringOutcome 객체로 반환합니다. 실패하면 오류 메시지를 반환합니다.
게임 세션으로 활성화되지 않은 유휴 프로세스의 경우 호출은 Success
=True
및 GameSessionId
=""
를 반환합니다.
예
Aws::GameLift::AwsStringOutcome sessionIdOutcome = Aws::GameLift::Server::GetGameSessionId();
GetTerminationTime()
종료 시간을 사용할 수 있는 경우 서버 프로세스가 종료되도록 예약된 시간을 반환합니다. 서버 프로세스는 Amazon GameLift에서 onProcessTerminate()
콜백을 수신한 후 작업을 수행합니다. Amazon GameLift에서 onProcessTerminate()
을 호출하는 이유는 다음과 같습니다.
-
서버 프로세스가 상태 불량을 보고했거나 Amazon GameLift에 응답하지 않은 경우
-
스케일 다운 이벤트 중에 인스턴스를 종료하는 경우
-
스팟 인스턴스 중단으로 인해 인스턴스가 종료되는 경우
구문
AwsDateTimeOutcome GetTerminationTime()
반환 값
성공하면 종료 시간을 AwsDateTimeOutcome
객체로 반환합니다. 값은 종료 시간이며, 0001 00:00:00
이후 경과된 틱 수로 표시됩니다. 예를 들어, 날짜 시간 값 2020-09-13
12:26:40 -000Z
는 637355968000000000
틱 수와 같습니다. 사용 가능한 종료 시간이 없는 경우 오류 메시지를 반환합니다.
프로세스가 ProcessParameters.OnProcessTerminate() 콜백을 받지 못한 경우 오류 메시지가 반환됩니다. 서버 프로세스 종료에 대한 자세한 내용은 서버 프로세스 종료 알림에 응답 섹션을 참조하세요.
예
Aws::GameLift::AwsLongOutcome TermTimeOutcome = Aws::GameLift::Server::GetTerminationTime();
AcceptPlayerSession()
Amazon GameLift에 지정된 플레이어 세션 ID의 플레이어가 서버 프로세스에 연결되었고 검증이 필요함을 알립니다. Amazon GameLift는 플레이어 세션 ID가 유효한지 확인합니다. 플레이어 세션이 검증된 후 Amazon GameLift는 플레이어 슬롯의 상태를 RESERVED에서 ACTIVE로 변경합니다.
구문
GenericOutcome AcceptPlayerSession(String playerSessionId)
파라미터
- playerSessionId
-
새로운 플레이어 세션이 생성되었을 때 Amazon GameLift가 발행한 고유 ID입니다.
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
이 예제는 유효하지 않은 플레이어 세션 ID의 검증 및 거부를 포함하는 연결 요청을 처리합니다.
void ReceiveConnectingPlayerSessionID (Connection& connection, const std::string& playerSessionId) { Aws::GameLift::GenericOutcome connectOutcome = Aws::GameLift::Server::AcceptPlayerSession(
playerSessionId
); if(connectOutcome.IsSuccess()) { connectionToSessionMap.emplace(connection, playerSessionId); connection.Accept(); } else { connection.Reject(connectOutcome.GetError().GetMessage(); } }
RemovePlayerSession()
플레이어가 서버 프로세스와의 연결이 끊겼음을 Amazon GameLift에 알립니다. 이에 따라 Amazon GameLift는 플레이어 슬롯을 사용 가능한 것으로 변경합니다.
구문
GenericOutcome RemovePlayerSession(String playerSessionId)
파라미터
playerSessionId
-
새로운 플레이어 세션이 생성되었을 때 Amazon GameLift가 발행한 고유 ID입니다.
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
Aws::GameLift::GenericOutcome disconnectOutcome = Aws::GameLift::Server::RemovePlayerSession(
playerSessionId
);
DescribePlayerSessions()
설정, 세션 메타데이터 및 플레이어 데이터 등의 플레이어 세션 데이터를 가져옵니다. 이 메서드를 사용하여 다음에 대한 정보를 얻을 수 있습니다.
-
단일 플레이어 세션
-
게임 세션의 모든 플레이어 세션
-
단일 플레이어 ID와 연결된 모든 플레이어 세션
구문
DescribePlayerSessionsOutcome DescribePlayerSessions(DescribePlayerSessionsRequest describePlayerSessionsRequest)
파라미터
- DescribePlayerSessionsRequest
-
검색할 플레이어 세션을 설명하는 DescribePlayerSessionsRequest 객체입니다.
반환 값
성공하는 경우, 요청 파라미터에 적합한 플레이어 세션 객체 집합이 들어 있는 DescribePlayerSessionsOutcome 객체를 반환합니다.
예
다음은 지정된 게임 세션에 활성 상태로 연결되어 있는 모든 플레이어 세션을 요청하는 예입니다. NextToken을 생략하고 제한 값을 10으로 설정하면, Amazon GameLift가 요청과 일치하는 처음 10개의 플레이어 세션 레코드를 반환합니다.
// Set request parameters Aws::GameLift::Server::Model::DescribePlayerSessionsRequest request; request.SetPlayerSessionStatusFilter(Aws::GameLift::Server::Model::PlayerSessionStatusMapper::GetNameForPlayerSessionStatus(Aws::GameLift::Server::Model::PlayerSessionStatus::Active)); request.SetLimit(
10
); request.SetGameSessionId("the game session ID
"); // can use GetGameSessionId() // Call DescribePlayerSessions Aws::GameLift::DescribePlayerSessionsOutcome playerSessionsOutcome = Aws::GameLift::Server::DescribePlayerSessions(request);
StartMatchBackfill()
FlexMatch를 통해 생성된 게임 세션에서 열린 슬롯에 참여할 새로운 플레이어를 찾는 요청을 보냅니다. 자세한 내용은 FlexMatch 채우기 기능을 참조하세요.
이 작업은 비동기식입니다. 새로운 플레이어가 매치되면 Amazon GameLift는 콜백 함수 OnUpdateGameSession()
을 사용하여 업데이트된 매치메이커 데이터를 전달합니다.
서버 프로세스는 한 번에 하나의 활성 매치 채우기 요청만 할 수 있습니다. 새 요청을 보내려면 먼저 StopMatchBackfill()을 호출하여 원본 요청을 취소해야 합니다.
구문
StartMatchBackfillOutcome StartMatchBackfill (StartMatchBackfillRequest startBackfillRequest);
파라미터
- StartMatchBackfillRequest
-
다음 정보를 전달하는 StartMatchBackfillRequest 객체입니다.
-
채우기 요청에 할당할 티켓 ID. 이 정보를 선택 사항입니다. ID를 제공하지 않으면 Amazon GameLift가 ID를 생성합니다.
-
요청을 보낼 매치메이커. 전체 구성 ARN이 필요합니다. 이 값은 게임 세션의 매치메이커 데이터에 있습니다.
-
채울 게임 세션의 ID입니다.
-
게임 세션의 현재 플레이어에 대해 사용 가능한 매치메이킹 데이터입니다.
-
반환 값
매치 채우기 티켓 ID와 함께 StartMatchBackfillOutcome 객체나 오류 메시지를 포함한 결함을 반환합니다.
예
// Build a backfill request std::vector<Player> players; Aws::GameLift::Server::Model::StartMatchBackfillRequest startBackfillRequest; startBackfillRequest.SetTicketId("
1111aaaa-22bb-33cc-44dd-5555eeee66ff
"); // optional, autogenerated if not provided startBackfillRequest.SetMatchmakingConfigurationArn("arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig
"); //from the game session matchmaker data startBackfillRequest.SetGameSessionArn("the game session ARN
"); // can use GetGameSessionId() startBackfillRequest.SetPlayers(players); // from the game session matchmaker data // Send backfill request Aws::GameLift::StartMatchBackfillOutcome backfillOutcome = Aws::GameLift::Server::StartMatchBackfill(startBackfillRequest); // Implement callback function for backfill void Server::OnUpdateGameSession(Aws::GameLift::Server::Model::GameSession gameSession, Aws::GameLift::Server::Model::UpdateReason updateReason, std::string backfillTicketId) { // handle status messages // perform game-specific tasks to prep for newly matched players }
StopMatchBackfill()
활성 매치 채우기 요청을 취소합니다. 자세한 내용은 FlexMatch 채우기 기능을 참조하세요.
구문
GenericOutcome StopMatchBackfill (StopMatchBackfillRequest stopBackfillRequest);
파라미터
- StopMatchBackfillRequest
-
다음은 취소할 매치메이킹 티켓을 식별하는 StopMatchBackfillRequest 객체입니다.
-
채우기 요청에 할당된 티켓 ID
-
채우기 요청을 보낸 매치메이커
-
채우기 요청과 연결된 게임 세션
-
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
// Set backfill stop request parameters Aws::GameLift::Server::Model::StopMatchBackfillRequest stopBackfillRequest; stopBackfillRequest.SetTicketId("
1111aaaa-22bb-33cc-44dd-5555eeee66ff
"); stopBackfillRequest.SetGameSessionArn("the game session ARN
"); // can use GetGameSessionId() stopBackfillRequest.SetMatchmakingConfigurationArn("arn:aws:gamelift:us-west-2:111122223333:matchmakingconfiguration/MyMatchmakerConfig
"); // from the game session matchmaker data Aws::GameLift::GenericOutcome stopBackfillOutcome = Aws::GameLift::Server::StopMatchBackfill(stopBackfillRequest);
GetComputeCertificate()
Amazon GameLift Anywhere 컴퓨팅 리소스 및 Amazon GameLift 간의 네트워크 연결을 암호화하는 데 사용되는 TLS 인증서의 경로를 검색합니다. Amazon GameLift Anywhere 플릿에 컴퓨팅 디바이스를 등록할 때 인증서 경로를 사용할 수 있습니다. 자세한 내용은 RegisterCompute을 참조하세요.
구문
GetComputeCertificateOutcome Server::GetComputeCertificate()
반환 값
GetComputeCertificateOutcome을 반환합니다.
예
Aws::GameLift::GetComputeCertificateOutcome certificate = Aws::GameLift::Server::GetComputeCertificate();
GetFleetRoleCredentials()
Amazon GameLift가 다른 AWS 서비스와 상호 작용할 수 있도록 승인하는 IAM 역할 자격 증명을 검색합니다. 자세한 내용은 플릿에서 다른 AWS 리소스와 통신 단원을 참조하십시오.
구문
GetFleetRoleCredentialsOutcome GetFleetRoleCredentials(GetFleetRoleCredentialsRequest request);
파라미터
GetFleetRoleCredentialsRequest
반환 값
GetFleetRoleCredentialsOutcome 객체를 반환합니다.
예
// form the fleet credentials request Aws::GameLift::Server::Model::GetFleetRoleCredentialsRequest getFleetRoleCredentialsRequest; getFleetRoleCredentialsRequest.SetRoleArn("
arn:aws:iam::123456789012:role/service-role/exampleGameLiftAction
"); Aws::GameLift::GetFleetRoleCredentialsOutcome credentials = Aws::GameLift::Server::GetFleetRoleCredentials(getFleetRoleCredentialsRequest);
이 예제에서는 감사 목적으로 RoleSessionName
값(선택 사항)을 사용하여 자격 증명 세션에 이름을 할당하는 방법을 보여줍니다. 역할 세션 이름을 제공하지 않으면 기본값인 “[fleet-id]
-[host-id]
”가 사용됩니다.
// form the fleet credentials request Aws::GameLift::Server::Model::GetFleetRoleCredentialsRequest getFleetRoleCredentialsRequest; getFleetRoleCredentialsRequest.SetRoleArn("
arn:aws:iam::123456789012:role/service-role/exampleGameLiftAction
"); getFleetRoleCredentialsRequest.SetRoleSessionName("MyFleetRoleSession
"); Aws::GameLift::GetFleetRoleCredentialsOutcome credentials = Aws::GameLift::Server::GetFleetRoleCredentials(getFleetRoleCredentialsRequest);
Destroy()
Amazon GameLift Game Server SDK를 메모리에서 분리합니다. ProcessEnding()
이후 및 프로세스를 종료하기 전에 이 메서드를 호출하는 것이 가장 좋습니다. Anywhere 플릿을 사용 중이고 게임 세션 이후마다 서버 프로세스를 종료하지 않는 경우, Destroy()
및 InitSDK()
를 차례로 호출하여 Amazon GameLift가 게임 세션을 ProcessReady()
로 호스팅할 준비가 되었음을 알리기 전에 다시 초기화합니다.
구문
GenericOutcome Aws::GameLift::Server::Destroy();
파라미터
파라미터는 없습니다.
반환 값
성공 또는 실패와 함께 오류 메시지로 구성된 일반적인 결과를 반환합니다.
예
Aws::GameLift::GenericOutcome processEndingOutcome = Aws::GameLift::Server::ProcessEnding(); Aws::GameLift::Server::Destroy(); // Exit the process with success or failure if (processEndingOutcome.IsSuccess()) { exit(0); } else { cout << "ProcessEnding() failed. Error: " << processEndingOutcome.GetError().GetErrorMessage(); exit(-1); }