Skip to content

Commit eb537ee

Browse files
committed
[OF-1784] refac: Update to use case with logging
1 parent c5e5ae6 commit eb537ee

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Library/include/CSP/Systems/Multiplayer/Scope.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class CSP_API ScopeResult : public ResultBase
9999
/// @return const Scope& : The scope retrieved by this result.
100100
const Scope& GetScope() const;
101101

102+
CSP_NO_EXPORT ScopeResult(csp::systems::EResultCode ResCode, uint16_t HttpResCode);
103+
102104
private:
103105
ScopeResult(void*) {};
104106

Library/src/Systems/Multiplayer/MultiplayerSystem.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Services/ApiBase/ApiBase.h"
44
#include "Services/MultiplayerService/Api.h"
55
#include "Services/MultiplayerService/Dto.h"
6+
#include "Systems/ResultHelpers.h"
67

78
namespace chs = csp::services::generated;
89

@@ -44,13 +45,18 @@ void MultiplayerSystem::UpdateScopeById(const csp::common::String& ScopeId, cons
4445

4546
auto PubSubModelDto = std::make_shared<chs::multiplayerservice::PubSubModel>();
4647

47-
if (Scope.PubSubType == PubSubModelType::Global)
48+
switch (Scope.PubSubType)
4849
{
50+
case PubSubModelType::Global:
4951
PubSubModelDto->SetValue(chs::multiplayerservice::PubSubModel::ePubSubModel::GLOBAL);
50-
}
51-
else if (Scope.PubSubType == PubSubModelType::Object)
52-
{
52+
break;
53+
case PubSubModelType::Object:
5354
PubSubModelDto->SetValue(chs::multiplayerservice::PubSubModel::ePubSubModel::OBJECT);
55+
break;
56+
default:
57+
LogSystem->LogMsg(csp::common::LogLevel::Error, "Invalid PubSubModel type specified");
58+
Callback(MakeInvalid<ScopeResult>());
59+
return;
5460
}
5561

5662
Dto->SetPubSubModel(PubSubModelDto);

Library/src/Systems/Multiplayer/Scope.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ void DtoToScope(const chs::multiplayerservice::ScopeDto& Dto, csp::systems::Scop
5555

5656
const Scope& ScopeResult::GetScope() const { return Scope; }
5757

58+
ScopeResult::ScopeResult(csp::systems::EResultCode ResCode, uint16_t HttpResCode)
59+
: ResultBase { ResCode, HttpResCode }
60+
{
61+
}
62+
5863
void ScopeResult::OnResponse(const csp::services::ApiResponseBase* ApiResponse)
5964
{
6065
ResultBase::OnResponse(ApiResponse);

0 commit comments

Comments
 (0)