QcSessionCore Class
The part of a client session that keeps time (decision E-560): the connection to the server, the ticks on the 50 ms grid (QcTickPacer) and the local player's prediction with what it needs, its own mirror of the blocks (sharing the immutable chunks, with the player's predicted blocks, decision E-853) and of the creatures that push them (QcPushBodies, decision E-882), the game mode's wish to fly and whether the player is dead. More...
| Header: | #include <clientcore/tick/QcSessionCore.h> |
| Inherits: | QObject |
Public Types
Public Functions
| QcSessionCore(std::unique_ptr<QcTransport> transport, QcSessionCore::Sink sink) | |
| QcSessionCore(const QcSessionCore &) | |
| QcSessionCore(QcSessionCore &&) | |
| virtual | ~QcSessionCore() override |
| void | apply(const QcSessionCommand &command) |
| void | attach(std::unique_ptr<QcTransport> transport) |
| QcLatencyProbe & | latency() |
| const QcLatencyProbe & | latency() const |
| QcLinkStats & | linkStats() |
| void | moveAllToThread(QThread *thread) |
| QcTickPacer & | pacer() |
| const QcTickPacer & | pacer() const |
| int | runDueTicks() |
| void | setClock(QcSessionCore::Clock clock) |
| void | shutdown() |
| void | stop() |
| bool | tick() |
| bool | transportKeepsItsThread() const |
| QcSessionCore & | operator=(QcSessionCore &&) |
| QcSessionCore & | operator=(const QcSessionCore &) |
Detailed Description
Every tick it predicts and sends the input; every message it receives it applies to that state and passes on, with the ticks and reconciliations, as one ordered stream of QcSessionEvent to its sink. Lives in the session's tick thread (QcSessionLink) or, without one, in the session's thread; every member is used in that thread only, except pacer().timing(), linkStats() and latency().
Member Type Documentation
[alias] QcSessionCore::Clock
Nanoseconds on a steady clock; the ticks are paced on it.
[alias] QcSessionCore::Sink
Takes the core's events in order.
Member Function Documentation
QcSessionCore::QcSessionCore(std::unique_ptr<QcTransport> transport, QcSessionCore::Sink sink)
Without a transport the core waits for attach() before it starts.
[delete] QcSessionCore::QcSessionCore(const QcSessionCore &)
Copy-constructs an instance of QcSessionCore. This function is deleted.
[delete] QcSessionCore::QcSessionCore(QcSessionCore &&)
Move-constructs an instance of QcSessionCore. This function is deleted.
[override virtual noexcept] QcSessionCore::~QcSessionCore()
Shuts down (shutdown()) if that did not happen yet.
void QcSessionCore::apply(const QcSessionCommand &command)
Carries out the session's command.
void QcSessionCore::attach(std::unique_ptr<QcTransport> transport)
Takes the connection's transport, in the core's thread; once, before Start, when the core was made without one (a TLS transport made in the core's thread, decision E-872).
QcLatencyProbe &QcSessionCore::latency()
Returns the round trip to the server, measured with probes from the ticks (decision E-886).
const QcLatencyProbe &QcSessionCore::latency() const
Returns the round trip to the server, read-only.
QcLinkStats &QcSessionCore::linkStats()
Returns the round trip of the inputs and bytes of the connection (health line, decision E-834).
void QcSessionCore::moveAllToThread(QThread *thread)
Moves the core with its connection and transport to thread; called in the core's thread (or before the thread runs). Never with a transport that keeps its thread.
QcTickPacer &QcSessionCore::pacer()
Returns the due times of the timer-driven ticks and their punctuality, writable.
const QcTickPacer &QcSessionCore::pacer() const
Returns the due times of the timer-driven ticks and their punctuality.
int QcSessionCore::runDueTicks()
Runs the ticks due on the clock (QcTickPacer::take) and returns how many ran; the timer calls it after Start. Until the world plays, the grid starts anew instead: no tick is due then.
void QcSessionCore::setClock(QcSessionCore::Clock clock)
Replaces the steady clock with clock (tests); before Start.
void QcSessionCore::shutdown()
Stops and closes and destroys the connection.
void QcSessionCore::stop()
Stops ticking and taking messages; the connection stays (it may leave the thread with the core and close there, so that a TCP socket lingers in a thread that goes on).
bool QcSessionCore::tick()
Runs one tick of the local player. Returns false while the world does not play yet or after the close.
bool QcSessionCore::transportKeepsItsThread() const
Returns whether the connection's transport must stay in the thread it was made in (QcTransport::keepsItsThread).
[delete] QcSessionCore &QcSessionCore::operator=(QcSessionCore &&)
Move-assigns other to this QcSessionCore instance. This function is deleted.
[delete] QcSessionCore &QcSessionCore::operator=(const QcSessionCore &)
Copy-assigns other to this QcSessionCore instance. This function is deleted.