mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 11:18:22 -05:00
Coding style cleanup
This commit is contained in:
@@ -125,7 +125,8 @@ void Connection::handleMessage(const std::string& message) {
|
||||
message
|
||||
));
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
std::string sanitizedString = message;
|
||||
std::transform(
|
||||
message.begin(),
|
||||
@@ -183,7 +184,8 @@ void Connection::handleJson(const nlohmann::json& json) {
|
||||
if (!topic->isDone()) {
|
||||
_topics.emplace(topicId, std::move(topic));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!isAuthorized()) {
|
||||
LERROR("Connection isn't authorized.");
|
||||
return;
|
||||
|
||||
@@ -155,7 +155,8 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config)
|
||||
const std::string type = config.value<std::string>(TypeInfo.identifier);
|
||||
if (type == TcpSocketType) {
|
||||
_type = static_cast<int>(InterfaceType::TcpSocket);
|
||||
} else if (type == WebSocketType) {
|
||||
}
|
||||
else if (type == WebSocketType) {
|
||||
_type = static_cast<int>(InterfaceType::WebSocket);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +51,16 @@ bool AuthorizationTopic::isDone() const {
|
||||
void AuthorizationTopic::handleJson(const nlohmann::json& json) {
|
||||
if (isDone()) {
|
||||
_connection->sendJson(wrappedPayload({ KeyStatus, Authorized }));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
try {
|
||||
auto providedKey = json.at("key").get<std::string>();
|
||||
if (authorize(providedKey)) {
|
||||
_connection->setAuthorized(true);
|
||||
_connection->sendJson(wrappedPayload({ KeyStatus, Authorized }));
|
||||
LINFO("Client successfully authorized.");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
_connection->sendJson(wrappedPayload({ KeyStatus, IncorrectKey }));
|
||||
}
|
||||
} catch (const std::out_of_range&) {
|
||||
|
||||
@@ -55,9 +55,11 @@ void DocumentationTopic::handleJson(const nlohmann::json& json) {
|
||||
// ghoul::Dictionary objects from ScriptEngine, FactoryManager, and KeybindingManager.
|
||||
if (requestedType == TypeLua) {
|
||||
response = json::parse(global::scriptEngine.generateJson());
|
||||
} else if (requestedType == TypeFactories) {
|
||||
}
|
||||
else if (requestedType == TypeFactories) {
|
||||
response = json::parse(FactoryManager::ref().generateJson());
|
||||
} else if (requestedType == TypeKeyboard) {
|
||||
}
|
||||
else if (requestedType == TypeKeyboard) {
|
||||
response = json::parse(global::keybindingManager.generateJson());
|
||||
}
|
||||
|
||||
|
||||
@@ -70,11 +70,14 @@ namespace {
|
||||
std::string luaLiteralFromJson(nlohmann::json value) {
|
||||
if (value.is_string()) {
|
||||
return "'" + escapedLuaString(value.get<std::string>()) + "'";
|
||||
} else if (value.is_boolean()) {
|
||||
}
|
||||
else if (value.is_boolean()) {
|
||||
return value.get<bool>() ? "true" : "false";
|
||||
} else if (value.is_number()) {
|
||||
}
|
||||
else if (value.is_number()) {
|
||||
return std::to_string(value.get<double>());
|
||||
} else if (value.is_array()) {
|
||||
}
|
||||
else if (value.is_array()) {
|
||||
std::string literal = "{";
|
||||
for (nlohmann::json::iterator it = value.begin(); it != value.end(); ++it) {
|
||||
literal += luaLiteralFromJson(it.value()) += ",";
|
||||
@@ -82,7 +85,8 @@ namespace {
|
||||
literal.pop_back(); // remove last comma
|
||||
literal += "}";
|
||||
return literal;
|
||||
} else if (value.is_object()) {
|
||||
}
|
||||
else if (value.is_object()) {
|
||||
std::string literal = "{";
|
||||
for (nlohmann::json::iterator it = value.begin(); it != value.end(); ++it) {
|
||||
literal += it.key() + "=" + luaLiteralFromJson(it.value()) += ",";
|
||||
@@ -90,7 +94,8 @@ namespace {
|
||||
literal.pop_back(); // remove last comma
|
||||
literal += "}";
|
||||
return literal;
|
||||
}{
|
||||
}
|
||||
else {
|
||||
return "nil";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,8 @@ void ShortcutTopic::handleJson(const nlohmann::json& input) {
|
||||
if (event == StartSubscription) {
|
||||
// TODO: Subscribe to shortcuts and keybindings
|
||||
// shortcutManager.subscribe(); ...
|
||||
} else if (event == StopSubscription) {
|
||||
}
|
||||
else if (event == StopSubscription) {
|
||||
// TODO: Unsubscribe to shortcuts and keybindings
|
||||
// shortcutManager.unsubscribe(); ...
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user