* @brief Set TCP port */
| 137 | * @brief Set TCP port |
| 138 | */ |
| 139 | API::CommandResponse API::Handlers::NetworkHandler::setTcpPort(const QString& id, |
| 140 | const QJsonObject& params) |
| 141 | { |
| 142 | if (!params.contains(QStringLiteral("port"))) { |
| 143 | return CommandResponse::makeError( |
| 144 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: port")); |
| 145 | } |
| 146 | |
| 147 | const int port = params.value(QStringLiteral("port")).toInt(); |
| 148 | if (port < 1 || port > 65535) { |
| 149 | return CommandResponse::makeError( |
| 150 | id, ErrorCode::InvalidParam, QStringLiteral("Port must be between 1 and 65535")); |
| 151 | } |
| 152 | |
| 153 | IO::ConnectionManager::instance().network()->setTcpPort(static_cast<quint16>(port)); |
| 154 | |
| 155 | QJsonObject result; |
| 156 | result[QStringLiteral("tcpPort")] = port; |
| 157 | return CommandResponse::makeSuccess(id, result); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * @brief Set UDP local port |