QcControlContext Class
State the control commands share: the session, the response output, the running command and the chat lines received while it runs. More...
| Header: | #include <clientcore/control/QcControlContext.h> |
Public Functions
| std::optional<QcControlActiveCommand> & | active() |
| void | appendChat(const QString &text) |
| void | begin(QcControlActiveCommand command) |
| const QStringList & | chatHistory() const |
| void | clearChatHistory() |
| void | clearChatLog() |
| void | fail(const QJsonObject &request, const QString &message) |
| int | failedRequests() const |
| void | finish(const QJsonObject &request, QJsonObject response) |
| bool | isActive() const |
| QcControlReports | reports() const |
| QcClientSession * | session() const |
| void | setActiveError(const QString &error) |
| void | setSession(QcClientSession *session) |
| QString | takeActiveError() |
| void | waitTicks(const QJsonObject &request, quint64 startTick, int ticks, std::function<QJsonObject ()> result = {}) |
Static Public Members
| const qsizetype | chatHistoryLimit |
Detailed Description
Member Function Documentation
std::optional<QcControlActiveCommand> &QcControlContext::active()
Returns the command that runs on the following ticks; nothing while none runs.
void QcControlContext::appendChat(const QString &text)
Keeps the received chat line text for the running request and the chat history.
void QcControlContext::begin(QcControlActiveCommand command)
Runs command on the following ticks until it completes.
const QStringList &QcControlContext::chatHistory() const
Returns every chat line received, oldest first, also while no request ran (at most chatHistoryLimit).
void QcControlContext::clearChatHistory()
Forgets the chat history.
void QcControlContext::clearChatLog()
Forgets the chat lines of the running request.
void QcControlContext::fail(const QJsonObject &request, const QString &message)
Writes a failure of request with the error message (with the request's id and command).
int QcControlContext::failedRequests() const
Returns the number of requests that failed.
void QcControlContext::finish(const QJsonObject &request, QJsonObject response)
Writes response to request as a success (with the request's id).
bool QcControlContext::isActive() const
Returns whether a command runs on the following ticks.
QcControlReports QcControlContext::reports() const
Returns the JSON views of the session; only valid while a session is set.
QcClientSession *QcControlContext::session() const
Returns the session the commands act on; null while there is none.
See also setSession().
void QcControlContext::setActiveError(const QString &error)
Sets error, set by a step that completes unsuccessfully; the active request then fails with it.
void QcControlContext::setSession(QcClientSession *session)
Switches to session.
See also session().
QString QcControlContext::takeActiveError()
Returns the error a step set and forgets it; empty for none.
void QcControlContext::waitTicks(const QJsonObject &request, quint64 startTick, int ticks, std::function<QJsonObject ()> result = {})
Completes request ticks client ticks after startTick with result (the player status when unset).
Member Variable Documentation
const qsizetype QcControlContext::chatHistoryLimit
Lines kept for the chatLog command.