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

Method disconnectClient

app/src/API/Server.cpp:776–792  ·  view source on GitHub ↗

* @brief Sends an error response and disconnects the client. */

Source from the content-addressed store, hash-verified

774 * @brief Sends an error response and disconnects the client.
775 */
776void API::Server::disconnectClient(QTcpSocket* socket,
777 ConnectionState& state,
778 const QString& errorCode,
779 const QString& errorMessage)
780{
781 Q_ASSERT(socket);
782 Q_ASSERT(!errorCode.isEmpty());
783
784 const QByteArray response =
785 CommandResponse::makeError(QString(), errorCode, errorMessage).toJsonBytes();
786 sendResponseToSocket(socket, response);
787
788 auto* worker = static_cast<ServerWorker*>(m_worker);
789 QMetaObject::invokeMethod(
790 worker, "disconnectSocket", Qt::QueuedConnection, Q_ARG(QTcpSocket*, socket));
791 state.buffer.clear();
792}
793
794/**
795 * @brief Validates rate limits and buffer capacity for incoming data.

Callers

nothing calls this directly

Calls 3

isEmptyMethod · 0.80
toJsonBytesMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected