/* * 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. * */ ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// // THIS CODE IS AUTOGENERATED, DO NOT MODIFY ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// #include "CloudGemPlayerAccount_precompiled.h" #include "AWS/ServiceAPI/CloudGemPlayerAccountClientComponent.h" namespace CloudGemPlayerAccount { namespace ServiceAPI { const char* LmbrAWS_CodeGen_Component_UUID= "{944353e1-ed91-11e6-aa43-80a589661b03}"; const char* LmbrAWS_CodeGen_ResponseHandler_UUID= "{65f32735-b675-4612-a9ba-95fda9510b14}"; const char* LmbrAWS_CodeGen_NotificationBus1_UUID= "{6486c8a9-3792-4d24-8619-eec3776a6077}"; const char* LmbrAWS_CodeGen_RequestBus1_UUID= "{a60705e4-8cf0-4727-abcc-f5f9867aa59f}"; const char* LmbrAWS_CodeGen_ServiceStatus_UUID= "{3aecc773-fc4c-4979-b9ed-dad443df93c4}"; const char* LmbrAWS_CodeGen_AccountResponse_UUID= "{54b61a23-124a-4f60-8a28-ecdc0a38201a}"; const char* LmbrAWS_CodeGen_UpdateAccountRequest_UUID= "{cffbf59d-ff4b-4e3c-8983-40092970b57b}"; void Configure() { // Insert any necessary CloudGemFramework configuration here } // redefs bool WriteJson(CloudGemFramework::JsonWriter& writer, const int& item) { return writer.Int(item); } bool WriteJson(CloudGemFramework::JsonWriter& writer, const AZStd::string& item) { return writer.String(item); } bool WriteJson(CloudGemFramework::JsonWriter& writer, const double& item) { return writer.Double(item); } bool WriteJson(CloudGemFramework::JsonWriter& writer, const UpdateAccountRequest& item) { bool ok = true; ok = ok && writer.StartObject(); ok = ok && writer.Key("PlayerName"); ok = ok && WriteJson(writer, item.PlayerName); ok = ok && writer.EndObject(); return ok; } bool WriteJson(CloudGemFramework::JsonWriter& writer, const AccountResponse& item) { bool ok = true; ok = ok && writer.StartObject(); ok = ok && writer.Key("PlayerName"); ok = ok && WriteJson(writer, item.PlayerName); ok = ok && writer.Key("AccountId"); ok = ok && WriteJson(writer, item.AccountId); ok = ok && writer.EndObject(); return ok; } bool WriteJson(CloudGemFramework::JsonWriter& writer, const ServiceStatus& item) { bool ok = true; ok = ok && writer.StartObject(); ok = ok && writer.Key("status"); ok = ok && WriteJson(writer, item.status); ok = ok && writer.EndObject(); return ok; } // Generated Function Parameters bool PutAccountRequest::Parameters::BuildRequest(CloudGemFramework::RequestBuilder& request) { bool ok = true; ok = ok && request.WriteJsonBodyParameter(*this); return ok; } bool PutAccountRequest::Parameters::WriteJson(CloudGemFramework::JsonWriter& writer) const { bool ok = true; ok = ok && CloudGemPlayerAccount::ServiceAPI::WriteJson(writer, UpdateAccountRequest); return ok; } bool GetAccountRequest::Parameters::BuildRequest(CloudGemFramework::RequestBuilder& request) { bool ok = true; ok = ok && request.WriteJsonBodyParameter(*this); return ok; } bool GetAccountRequest::Parameters::WriteJson(CloudGemFramework::JsonWriter& writer) const { bool ok = true; return ok; } bool GetServiceStatusRequest::Parameters::BuildRequest(CloudGemFramework::RequestBuilder& request) { bool ok = true; ok = ok && request.WriteJsonBodyParameter(*this); return ok; } bool GetServiceStatusRequest::Parameters::WriteJson(CloudGemFramework::JsonWriter& writer) const { bool ok = true; return ok; } // CloudGemPlayerAccountNotificationBus void CloudGemPlayerAccountNotifications::OnPutAccountRequestSuccess(const AccountResponse response) { } void CloudGemPlayerAccountNotifications::OnPutAccountRequestError(const CloudGemFramework::Error error) { } void CloudGemPlayerAccountNotifications::OnGetAccountRequestSuccess(const AccountResponse response) { } void CloudGemPlayerAccountNotifications::OnGetAccountRequestError(const CloudGemFramework::Error error) { } void CloudGemPlayerAccountNotifications::OnGetServiceStatusRequestSuccess(const ServiceStatus response) { } void CloudGemPlayerAccountNotifications::OnGetServiceStatusRequestError(const CloudGemFramework::Error error) { } // BehaviorContext CloudGemPlayerAccountNotificationBus handler implementation void BehaviorCloudGemPlayerAccountNotificationBusHandler::OnPutAccountRequestSuccess(const AccountResponse response) { Call(FN_OnPutAccountRequestSuccess, response); } void BehaviorCloudGemPlayerAccountNotificationBusHandler::OnPutAccountRequestError(const CloudGemFramework::Error error) { Call(FN_OnPutAccountRequestError, error); } void BehaviorCloudGemPlayerAccountNotificationBusHandler::OnGetAccountRequestSuccess(const AccountResponse response) { Call(FN_OnGetAccountRequestSuccess, response); } void BehaviorCloudGemPlayerAccountNotificationBusHandler::OnGetAccountRequestError(const CloudGemFramework::Error error) { Call(FN_OnGetAccountRequestError, error); } void BehaviorCloudGemPlayerAccountNotificationBusHandler::OnGetServiceStatusRequestSuccess(const ServiceStatus response) { Call(FN_OnGetServiceStatusRequestSuccess, response); } void BehaviorCloudGemPlayerAccountNotificationBusHandler::OnGetServiceStatusRequestError(const CloudGemFramework::Error error) { Call(FN_OnGetServiceStatusRequestError, error); } // CloudGemPlayerAccountRequestBus void CloudGemPlayerAccountRequests::PutAccount(const UpdateAccountRequest& UpdateAccountRequest, CloudGemPlayerAccountResponseHandler* responseHandler) { } void CloudGemPlayerAccountRequests::GetAccount(CloudGemPlayerAccountResponseHandler* responseHandler) { } void CloudGemPlayerAccountRequests::GetServiceStatus(CloudGemPlayerAccountResponseHandler* responseHandler) { } // CloudGemPlayerAccountResponseHandler void CloudGemPlayerAccountResponseHandler::HandlePutAccountSuccess(PutAccountRequestJob* job, AZ::EntityId entityId) { EBUS_EVENT_ID(entityId, CloudGemPlayerAccountNotificationBus, OnPutAccountRequestSuccess, job->result); } void CloudGemPlayerAccountResponseHandler::HandlePutAccountError(PutAccountRequestJob* job, AZ::EntityId entityId) { EBUS_EVENT_ID(entityId, CloudGemPlayerAccountNotificationBus, OnPutAccountRequestError, job->error); } void CloudGemPlayerAccountResponseHandler::HandleGetAccountSuccess(GetAccountRequestJob* job, AZ::EntityId entityId) { EBUS_EVENT_ID(entityId, CloudGemPlayerAccountNotificationBus, OnGetAccountRequestSuccess, job->result); } void CloudGemPlayerAccountResponseHandler::HandleGetAccountError(GetAccountRequestJob* job, AZ::EntityId entityId) { EBUS_EVENT_ID(entityId, CloudGemPlayerAccountNotificationBus, OnGetAccountRequestError, job->error); } void CloudGemPlayerAccountResponseHandler::HandleGetServiceStatusSuccess(GetServiceStatusRequestJob* job, AZ::EntityId entityId) { EBUS_EVENT_ID(entityId, CloudGemPlayerAccountNotificationBus, OnGetServiceStatusRequestSuccess, job->result); } void CloudGemPlayerAccountResponseHandler::HandleGetServiceStatusError(GetServiceStatusRequestJob* job, AZ::EntityId entityId) { EBUS_EVENT_ID(entityId, CloudGemPlayerAccountNotificationBus, OnGetServiceStatusRequestError, job->error); } // CloudGemPlayerAccountClientComponent void CloudGemPlayerAccountClientComponent::Init() { m_defaultResponseHandler = AZStd::make_shared(); CloudGemPlayerAccount::ServiceAPI::Configure(); } void CloudGemPlayerAccountClientComponent::Activate() { CloudGemPlayerAccountRequestBus::Handler::BusConnect(m_entity->GetId()); } void CloudGemPlayerAccountClientComponent::Deactivate() { CloudGemPlayerAccountRequestBus::Handler::BusDisconnect(); } void CloudGemPlayerAccountClientComponent::PutAccount(const UpdateAccountRequest& UpdateAccountRequest, CloudGemPlayerAccountResponseHandler* responseHandler) { // Cache our entityId in case the entity goes away AZ::EntityId entityId; if (m_entity) { entityId = m_entity->GetId(); } // Cache our default response handler in case this component goes away AZStd::shared_ptr < CloudGemPlayerAccountResponseHandler > defaultResponseHandler = m_defaultResponseHandler; // Create job PutAccountRequestJob* requestJob = PutAccountRequestJob::Create( [responseHandler, defaultResponseHandler, entityId](PutAccountRequestJob* successJob) { // handle success CloudGemPlayerAccountResponseHandler* successHandler = responseHandler ? responseHandler : defaultResponseHandler.get(); if (successHandler) { successHandler->HandlePutAccountSuccess(successJob, entityId); } }, [responseHandler, defaultResponseHandler, entityId](PutAccountRequestJob* failedJob) { // handle error CloudGemPlayerAccountResponseHandler* failureHandler = responseHandler ? responseHandler : defaultResponseHandler.get(); if (failureHandler) { failureHandler->HandlePutAccountError(failedJob, entityId); } } ); requestJob->parameters.UpdateAccountRequest = UpdateAccountRequest; requestJob->Start(); } void CloudGemPlayerAccountClientComponent::GetAccount(CloudGemPlayerAccountResponseHandler* responseHandler) { // Cache our entityId in case the entity goes away AZ::EntityId entityId; if (m_entity) { entityId = m_entity->GetId(); } // Cache our default response handler in case this component goes away AZStd::shared_ptr < CloudGemPlayerAccountResponseHandler > defaultResponseHandler = m_defaultResponseHandler; // Create job GetAccountRequestJob* requestJob = GetAccountRequestJob::Create( [responseHandler, defaultResponseHandler, entityId](GetAccountRequestJob* successJob) { // handle success CloudGemPlayerAccountResponseHandler* successHandler = responseHandler ? responseHandler : defaultResponseHandler.get(); if (successHandler) { successHandler->HandleGetAccountSuccess(successJob, entityId); } }, [responseHandler, defaultResponseHandler, entityId](GetAccountRequestJob* failedJob) { // handle error CloudGemPlayerAccountResponseHandler* failureHandler = responseHandler ? responseHandler : defaultResponseHandler.get(); if (failureHandler) { failureHandler->HandleGetAccountError(failedJob, entityId); } } ); requestJob->Start(); } void CloudGemPlayerAccountClientComponent::GetServiceStatus(CloudGemPlayerAccountResponseHandler* responseHandler) { // Cache our entityId in case the entity goes away AZ::EntityId entityId; if (m_entity) { entityId = m_entity->GetId(); } // Cache our default response handler in case this component goes away AZStd::shared_ptr < CloudGemPlayerAccountResponseHandler > defaultResponseHandler = m_defaultResponseHandler; // Create job GetServiceStatusRequestJob* requestJob = GetServiceStatusRequestJob::Create( [responseHandler, defaultResponseHandler, entityId](GetServiceStatusRequestJob* successJob) { // handle success CloudGemPlayerAccountResponseHandler* successHandler = responseHandler ? responseHandler : defaultResponseHandler.get(); if (successHandler) { successHandler->HandleGetServiceStatusSuccess(successJob, entityId); } }, [responseHandler, defaultResponseHandler, entityId](GetServiceStatusRequestJob* failedJob) { // handle error CloudGemPlayerAccountResponseHandler* failureHandler = responseHandler ? responseHandler : defaultResponseHandler.get(); if (failureHandler) { failureHandler->HandleGetServiceStatusError(failedJob, entityId); } } ); requestJob->Start(); } bool UpdateAccountRequest::OnJsonKey(const char* key, CloudGemFramework::JsonReader& reader) { if (strcmp(key, "PlayerName") == 0) return reader.Accept(PlayerName); return reader.Ignore(); } void UpdateAccountRequest::Reflect(AZ::ReflectContext* reflection) { AZ::SerializeContext* serializeContext = azrtti_cast(reflection); if (serializeContext) { serializeContext->Class() ->Version(1); } AZ::BehaviorContext* behaviorContext = azrtti_cast(reflection); if (behaviorContext) { behaviorContext->Class("CloudGemPlayerAccount_UpdateAccountRequest") ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) ->Property("PlayerName", BehaviorValueProperty(&UpdateAccountRequest::PlayerName)) ; } } bool AccountResponse::OnJsonKey(const char* key, CloudGemFramework::JsonReader& reader) { if (strcmp(key, "PlayerName") == 0) return reader.Accept(PlayerName); if (strcmp(key, "AccountId") == 0) return reader.Accept(AccountId); return reader.Ignore(); } void AccountResponse::Reflect(AZ::ReflectContext* reflection) { AZ::SerializeContext* serializeContext = azrtti_cast(reflection); if (serializeContext) { serializeContext->Class() ->Version(1); } AZ::BehaviorContext* behaviorContext = azrtti_cast(reflection); if (behaviorContext) { behaviorContext->Class("CloudGemPlayerAccount_AccountResponse") ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) ->Property("PlayerName", BehaviorValueProperty(&AccountResponse::PlayerName)) ->Property("AccountId", BehaviorValueProperty(&AccountResponse::AccountId)) ; } } bool ServiceStatus::OnJsonKey(const char* key, CloudGemFramework::JsonReader& reader) { if (strcmp(key, "status") == 0) return reader.Accept(status); return reader.Ignore(); } void ServiceStatus::Reflect(AZ::ReflectContext* reflection) { AZ::SerializeContext* serializeContext = azrtti_cast(reflection); if (serializeContext) { serializeContext->Class() ->Version(1); } AZ::BehaviorContext* behaviorContext = azrtti_cast(reflection); if (behaviorContext) { behaviorContext->Class("CloudGemPlayerAccount_ServiceStatus") ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) ->Property("status", BehaviorValueProperty(&ServiceStatus::status)) ; } } } }