| 143 | // |
| 144 | // |
| 145 | void JsonRpcServer::finalConstruct(Variant vConfig) |
| 146 | { |
| 147 | TRACE_BEGIN; |
| 148 | |
| 149 | if (!vConfig.isDictionaryLike()) |
| 150 | error::InvalidArgument(SL, "Dictionary expected").throwException(); |
| 151 | if (!vConfig.has("port")) |
| 152 | error::InvalidArgument(SL, "Missing field <port>").throwException(); |
| 153 | if (!vConfig.has("processor")) |
| 154 | error::InvalidArgument(SL, "Missing field <processor>").throwException(); |
| 155 | |
| 156 | ChannelMode eChannelMode = ChannelMode::Both; |
| 157 | Variant vSerializeConfig; |
| 158 | if (vConfig.has("channelMode")) |
| 159 | { |
| 160 | eChannelMode = getChannelModeFromString(vConfig["channelMode"]); |
| 161 | if (eChannelMode == ChannelMode::Invalid) |
| 162 | error::InvalidArgument(SL, FMT("Invalid channel mode <" << |
| 163 | vConfig["channelMode"] << ">")).throwException(); |
| 164 | |
| 165 | if ((eChannelMode == ChannelMode::Encrypted) || (eChannelMode == ChannelMode::Both)) |
| 166 | { |
| 167 | std::string sEncryption = vConfig.get("encryption", ""); |
| 168 | if (sEncryption.empty()) |
| 169 | error::InvalidArgument(SL, "Field <encryption> is missing or empty").throwException(); |
| 170 | vSerializeConfig = Dictionary({ {"encryption", sEncryption} }); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | m_pHttpServer = std::make_unique<jsonrpc::HttpServer>(vConfig.get("port"), "", "", |
| 175 | vConfig.get("numThreads", 0)); |
| 176 | m_pServer = std::make_unique<detail::Server>(*m_pHttpServer, vConfig.get("processor"), |
| 177 | eChannelMode, vSerializeConfig); |
| 178 | |
| 179 | LOGLVL(Debug, "JSON-RPC server is created (channelMode: <" << |
| 180 | getChannelModeString(eChannelMode) << ">)"); |
| 181 | TRACE_END("Error during configuration"); |
| 182 | } |
| 183 | |
| 184 | // |
| 185 | // |
nothing calls this directly
no test coverage detected