MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setUdpLocalPort

Method setUdpLocalPort

app/src/API/Handlers/NetworkHandler.cpp:163–182  ·  view source on GitHub ↗

* @brief Set UDP local port */

Source from the content-addressed store, hash-verified

161 * @brief Set UDP local port
162 */
163API::CommandResponse API::Handlers::NetworkHandler::setUdpLocalPort(const QString& id,
164 const QJsonObject& params)
165{
166 if (!params.contains(QStringLiteral("port"))) {
167 return CommandResponse::makeError(
168 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: port"));
169 }
170
171 const int port = params.value(QStringLiteral("port")).toInt();
172 if (port < 0 || port > 65535) {
173 return CommandResponse::makeError(
174 id, ErrorCode::InvalidParam, QStringLiteral("Port must be between 0 and 65535"));
175 }
176
177 IO::ConnectionManager::instance().network()->setUdpLocalPort(static_cast<quint16>(port));
178
179 QJsonObject result;
180 result[QStringLiteral("udpLocalPort")] = port;
181 return CommandResponse::makeSuccess(id, result);
182}
183
184/**
185 * @brief Set UDP remote port

Callers

nothing calls this directly

Calls 3

networkMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected