-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Implementation of External Command Processor
- Loading branch information
Showing
8 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
class ExternalCommandProcessor | ||
{ | ||
// clang-format off | ||
std::unordered_map<std::wstring, std::function<nlohmann::json(const nlohmann::json&)>> functions = | ||
{ | ||
{ | ||
std::wstring(L"beam"), Beam | ||
}, | ||
{ | ||
|
||
} | ||
}; | ||
// clang-format on | ||
|
||
static nlohmann::json Beam(const nlohmann::json& parameters); | ||
|
||
public: | ||
std::optional<nlohmann::json> ProcessCommand(const nlohmann::json& command); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "PCH.hpp" | ||
#include "Core/Commands/ExternalCommandProcessor.hpp" | ||
#include "API/API.hpp" | ||
|
||
|
||
|
||
std::optional<nlohmann::json> ExternalCommandProcessor::ProcessCommand(const nlohmann::json& command) | ||
{ | ||
try | ||
{ | ||
std::wstring functionName = command.at("command").get<std::wstring>(); | ||
|
||
return functions[functionName](command); | ||
} | ||
catch (nlohmann::json::exception& ex) | ||
{ | ||
Logger::i()->Log(LogLevel::Warn, std::format(L"Exception was thrown while trying to process an external command. {}",StringUtils::stows(ex.what()))); | ||
} | ||
|
||
} | ||
|
||
nlohmann::json ExternalCommandProcessor::Beam(const nlohmann::json& parameters) | ||
{ | ||
const auto client = Hk::Client::GetClientIdFromCharName(parameters.at("characterName").get<std::wstring>()).Handle(); | ||
Hk::Player::Beam(client, parameters.at("baseName").get<std::wstring>()); | ||
|
||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters