Method calls handler
| 43 | // Method calls handler |
| 44 | // |
| 45 | void HandleMethodCall(const std::string& name, const Json::Value& input, Json::Value& output) override |
| 46 | { |
| 47 | ChannelMode eCallChannelMode = ChannelMode::Plain; |
| 48 | CMD_TRY |
| 49 | { |
| 50 | Variant vParams; |
| 51 | Variant vCommand; |
| 52 | |
| 53 | if (name == c_sEncryptedFieldName) |
| 54 | { |
| 55 | if ((m_eChannelMode != ChannelMode::Encrypted) && (m_eChannelMode != ChannelMode::Both)) |
| 56 | error::OperationNotSupported(SL, "Encrypted commands are not supported").throwException(); |
| 57 | eCallChannelMode = ChannelMode::Encrypted; |
| 58 | auto vData = decryptJsonValue(input); |
| 59 | vCommand = vData["command"]; |
| 60 | vParams = vData["params"]; |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | vCommand = name; |
| 65 | vParams = convertJsonValueToVariant(input); |
| 66 | } |
| 67 | |
| 68 | if ((m_eChannelMode != ChannelMode::Both) && (m_eChannelMode != eCallChannelMode)) |
| 69 | error::OperationNotSupported(SL, FMT("Wrong RPC channel mode <" << |
| 70 | getChannelModeString(eCallChannelMode) << ">")).throwException(); |
| 71 | |
| 72 | if (vParams.isEmpty()) |
| 73 | LOGLVL(Debug, "Process request <" << vCommand << ">"); |
| 74 | else |
| 75 | LOGLVL(Debug, "Process request <" << vCommand << ">, params:\n" << vParams); |
| 76 | Variant vResult = createCommand(m_vProcessor, vCommand, vParams)->execute(); |
| 77 | if (vResult.isEmpty()) |
| 78 | LOGLVL(Debug, "Send empty response"); |
| 79 | else |
| 80 | LOGLVL(Debug, "Send response:\n" << vResult); |
| 81 | |
| 82 | if (eCallChannelMode == ChannelMode::Encrypted) |
| 83 | encryptJsonValue(vResult, output, m_vSerializeConfig); |
| 84 | else |
| 85 | output = convertVariantToJsonValue(vResult); |
| 86 | } |
| 87 | CMD_PREPARE_CATCH |
| 88 | catch (error::TypeError& ex) |
| 89 | { |
nothing calls this directly
no test coverage detected