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

Method setUdpRemotePort

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

* @brief Set UDP remote port */

Source from the content-addressed store, hash-verified

185 * @brief Set UDP remote port
186 */
187API::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

Callers

nothing calls this directly

Calls 3

networkMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected