QtCraft API C++ classes QML types Handbook

QcClientAdmin Class

The client's side of the admin channel (decision E-848), part of QcClientSession: what an operator asks the server for and what came back, for the "Manage server" screen (stage 77.2) and the control interface. More...

Header: #include <clientcore/admin/QcClientAdmin.h>
Inherits: QObject

Public Types

struct Arrivals
Kind
enum class Refusal { None, Rights, Arguments, Confirmation, TooSoon }
Sender

Public Functions

const QcMsg::AdminCatalogue &catalogue() const
const QList<QcMsg::AdminChatLine> &chat() const
QcClientAdmin::Arrivals chatArrivals() const
void closed()
void follow(quint8 topics, QcMsg::AdminLogLine::Level logLevel = QcMsg::AdminLogLine::Level::Info)
const QcMsg::AdminHistory &history() const
QcClientAdmin::Refusal lastRefusal() const
const QcMsg::AdminLists &lists() const
const QList<QcMsg::AdminLogLine> &log() const
QcClientAdmin::Arrivals logArrivals() const
bool operatorRights() const
const QList<QcMsg::AdminPlayers::Entry> &players() const
bool receive(const QcMessage &message)
quint32 request(QcClientAdmin::Kind kind, const QStringList &arguments = {})
std::optional<QcMsg::AdminResult> result(quint32 id) const
quint32 runCommand(const QString &line)
void setSender(QcClientAdmin::Sender sender)
const QcMsg::AdminSettings &settings() const
const std::optional<QcMsg::AdminStatus> &status() const
quint8 topics() const
void welcomed()

Signals

void catalogueChanged()
void chatReceived()
void historyChanged()
void listsChanged()
void logReceived()
void operatorRightsChanged()
void playersChanged()
void refused(QcClientAdmin::Refusal reason, const QString &text)
void resultReceived(quint32 id)
void settingsChanged()
void statusChanged()

Static Public Members

const qsizetype chatLimit
QStringList display(const QcMsg::AdminResult &result)
const qsizetype logLimit
const qsizetype resultLimit

Detailed Description

The topics followed (status, chat, log) are sent once the server welcomed the client and again with every change; requests need the welcome and get a number, which the answer (QcMsg::AdminResult) carries. Every report the server sends replaces the one before; the status history grows with each status by its sample, chat and log lines are kept up to their limits. Only operators get answers: a refusal arrives as refused and as a failed result.

Member Type Documentation

[alias] QcClientAdmin::Kind

What a request asks for.

enum class QcClientAdmin::Refusal

Why the server refused (QcMsg::AdminResult::Refusal), for the screen to say the right thing: missing rights end every subscription.

ConstantValueDescription
QcClientAdmin::Refusal::None0not refused
QcClientAdmin::Refusal::Rights1the player is no operator
QcClientAdmin::Refusal::Arguments2the arguments do not fit the request
QcClientAdmin::Refusal::Confirmation3stopping needs the argument "confirm"
QcClientAdmin::Refusal::TooSoon4the request came again too soon

[alias] QcClientAdmin::Sender

Sends a message to the server.

Member Function Documentation

const QcMsg::AdminCatalogue &QcClientAdmin::catalogue() const

Returns the commands the server offers with their usage.

[signal] void QcClientAdmin::catalogueChanged()

The catalogue of commands came.

const QList<QcMsg::AdminChatLine> &QcClientAdmin::chat() const

Returns the chat lines that came, oldest first, at most chatLimit.

QcClientAdmin::Arrivals QcClientAdmin::chatArrivals() const

Returns how many chat lines came and how often the list was replaced.

[signal] void QcClientAdmin::chatReceived()

Chat lines came (chat(), chatArrivals()).

void QcClientAdmin::closed()

The connection closed: nothing goes out any more, what came stays.

[static] QStringList QcClientAdmin::display(const QcMsg::AdminResult &result)

Returns the lines of the answer result as the player reads them (translated, QcChatText::display).

void QcClientAdmin::follow(quint8 topics, QcMsg::AdminLogLine::Level logLevel = QcMsg::AdminLogLine::Level::Info)

Follows the topics (QcMsg::AdminSubscribe flags, 0 for none) with log lines from logLevel on.

const QcMsg::AdminHistory &QcClientAdmin::history() const

Returns the status history: one sample per status report.

[signal] void QcClientAdmin::historyChanged()

The status history changed.

QcClientAdmin::Refusal QcClientAdmin::lastRefusal() const

Returns why the latest answer of the server was refused; None when it was not.

const QcMsg::AdminLists &QcClientAdmin::lists() const

Returns the operator, ban and whitelist lists as the server last reported them.

[signal] void QcClientAdmin::listsChanged()

The lists of operators, bans and the whitelist came.

const QList<QcMsg::AdminLogLine> &QcClientAdmin::log() const

Returns the log lines that came, oldest first, at most logLimit.

QcClientAdmin::Arrivals QcClientAdmin::logArrivals() const

Returns how many log lines came and how often the list was replaced.

[signal] void QcClientAdmin::logReceived()

Log lines came (log(), logArrivals()).

bool QcClientAdmin::operatorRights() const

Returns whether the server said this player is an operator (decision E-863): it tells every player when they become one and when they stop being one; every answer that was not refused says so too.

[signal] void QcClientAdmin::operatorRightsChanged()

operatorRights() changed.

const QList<QcMsg::AdminPlayers::Entry> &QcClientAdmin::players() const

Returns the players as the server last reported them.

[signal] void QcClientAdmin::playersChanged()

A new list of players came.

bool QcClientAdmin::receive(const QcMessage &message)

Takes the admin message of the server. Returns false for every other message.

[signal] void QcClientAdmin::refused(QcClientAdmin::Refusal reason, const QString &text)

Emitted when the server refused a request or the subscription for reason; text is translated. With Rights the player is no operator (any more) and follows nothing now.

quint32 QcClientAdmin::request(QcClientAdmin::Kind kind, const QStringList &arguments = {})

Sends a request of kind with arguments. Returns its number, or 0 when it cannot go out (not welcomed, connection closed).

std::optional<QcMsg::AdminResult> QcClientAdmin::result(quint32 id) const

Returns the answer to request id while it is among the latest resultLimit; std::nullopt before it came.

[signal] void QcClientAdmin::resultReceived(quint32 id)

The answer to request id came (result()).

quint32 QcClientAdmin::runCommand(const QString &line)

Sends the command line as the operator typed it, with or without '/'. Returns the request's number, or 0 when it cannot go out.

void QcClientAdmin::setSender(QcClientAdmin::Sender sender)

Sets the way out to the server to sender (the session's connection).

const QcMsg::AdminSettings &QcClientAdmin::settings() const

Returns the game rules and server limits as last reported.

[signal] void QcClientAdmin::settingsChanged()

The game rules and server limits came.

const std::optional<QcMsg::AdminStatus> &QcClientAdmin::status() const

Returns the server's latest status report; nothing before the first.

[signal] void QcClientAdmin::statusChanged()

A new status report came.

quint8 QcClientAdmin::topics() const

Returns the topics followed (QcMsg::AdminSubscribe flags).

void QcClientAdmin::welcomed()

The server welcomed the client: the topics followed go out now.

Member Variable Documentation

const qsizetype QcClientAdmin::chatLimit

Chat lines kept at most; the oldest go first.

const qsizetype QcClientAdmin::logLimit

Log lines kept at most; the oldest go first.

const qsizetype QcClientAdmin::resultLimit

Answers kept at most (result()).