R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
rtype::ChatLog Class Reference

The chat messages to show, newest last, each for shown_for. More...

#include </__w/project-rtype/project-rtype/client/network/include/rtype/chat_log.hpp>

Public Types

using Clock = std::chrono::steady_clock
 Clock of the lines.
 

Public Member Functions

bool add (const ChatMessage &message, Clock::time_point now)
 Adds a message relayed by the server.
 
void refused (std::uint8_t reason, Clock::time_point now)
 Adds the reason a message of this client was not relayed.
 
void prune (Clock::time_point now)
 Drops the lines whose time is over.
 
const std::vector< PlayerNotice > & shown () const noexcept
 Lines to show, oldest first.
 
void clear () noexcept
 Forgets every line, for a new session.
 

Static Public Attributes

static constexpr std::chrono::seconds shown_for {8}
 How long a line stays.
 
static constexpr std::size_t max_shown = 6
 Most lines shown at once: a new one pushes out the oldest.
 

Detailed Description

The chat messages to show, newest last, each for shown_for.

A line is a PlayerNotice: the sender's number gives its color (lobby_player for a sender in the lobby, and for what the server refused), its text is "name: text". A message whose name or text breaks the rules of the protocol is ignored (RFC section 3.8).

Member Typedef Documentation

◆ Clock

using rtype::ChatLog::Clock = std::chrono::steady_clock

Clock of the lines.

Member Function Documentation

◆ add()

bool rtype::ChatLog::add ( const ChatMessage &  message,
Clock::time_point  now 
)

Adds a message relayed by the server.

Parameters
messageIts sender and text.
nowTime it is shown from.
Returns
false if it was ignored.

◆ clear()

void rtype::ChatLog::clear ( )
noexcept

Forgets every line, for a new session.

◆ prune()

void rtype::ChatLog::prune ( Clock::time_point  now)

Drops the lines whose time is over.

Parameters
nowCurrent time.

◆ refused()

void rtype::ChatLog::refused ( std::uint8_t  reason,
Clock::time_point  now 
)

Adds the reason a message of this client was not relayed.

Parameters
reasonreason of the ChatRejected, as received.
nowTime it is shown from.

◆ shown()

const std::vector< PlayerNotice > & rtype::ChatLog::shown ( ) const
noexcept

Lines to show, oldest first.

Returns
The lines.

Member Data Documentation

◆ max_shown

constexpr std::size_t rtype::ChatLog::max_shown = 6
staticconstexpr

Most lines shown at once: a new one pushes out the oldest.

◆ shown_for

constexpr std::chrono::seconds rtype::ChatLog::shown_for {8}
staticconstexpr

How long a line stays.


The documentation for this class was generated from the following file: