* @brief Set UDP remote port */
| 185 | * @brief Set UDP remote port |
| 186 | */ |
| 187 | API::CommandResponse API::Handlers::NetworkHandler::setUdpRemotePort(const QString& id, |
| 188 | const QJsonObject& params) |
| 189 | { |
| 190 | if (!params.contains(QStringLiteral("port"))) { |
| 191 | return CommandResponse::makeError( |
| 192 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: port")); |
| 193 | } |
| 194 | |
| 195 | const int port = params.value(QStringLiteral("port")).toInt(); |
| 196 | if (port < 1 || port > 65535) { |
| 197 | return CommandResponse::makeError( |
| 198 | id, ErrorCode::InvalidParam, QStringLiteral("Port must be between 1 and 65535")); |
| 199 | } |
| 200 | |
| 201 | IO::ConnectionManager::instance().network()->setUdpRemotePort(static_cast<quint16>(port)); |
| 202 | |
| 203 | QJsonObject result; |
| 204 | result[QStringLiteral("udpRemotePort")] = port; |
| 205 | return CommandResponse::makeSuccess(id, result); |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * @brief Set socket type |