* @brief Sends an error response and disconnects the client. */
| 774 | * @brief Sends an error response and disconnects the client. |
| 775 | */ |
| 776 | void 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. |
nothing calls this directly
no test coverage detected