R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
chat_log.hpp
Go to the documentation of this file.
1
3#pragma once
4#include <rtype/chat.hpp>
6
7#include <chrono>
8#include <cstddef>
9#include <cstdint>
10#include <string>
11#include <vector>
12
13namespace rtype {
14
19class ChatLog {
20public:
22 using Clock = std::chrono::steady_clock;
24 static constexpr std::chrono::seconds shown_for{8};
26 static constexpr std::size_t max_shown = 6;
27
32 bool add(const ChatMessage& message, Clock::time_point now);
33
37 void refused(std::uint8_t reason, Clock::time_point now);
38
41 void prune(Clock::time_point now);
42
45 [[nodiscard]] const std::vector<PlayerNotice>& shown() const noexcept;
46
48 void clear() noexcept;
49
50private:
51 void push(PlayerNotice line);
52
53 std::vector<PlayerNotice> shown_;
54};
55
59[[nodiscard]] std::string chat_rejection_text(std::uint8_t reason);
60
61} // namespace rtype
TCP messages of the chat (RFC section 3.8): encoding, decoding and text rules.
The chat messages to show, newest last, each for shown_for.
Definition chat_log.hpp:19
void clear() noexcept
Forgets every line, for a new session.
void prune(Clock::time_point now)
Drops the lines whose time is over.
static constexpr std::chrono::seconds shown_for
How long a line stays.
Definition chat_log.hpp:24
const std::vector< PlayerNotice > & shown() const noexcept
Lines to show, oldest first.
void refused(std::uint8_t reason, Clock::time_point now)
Adds the reason a message of this client was not relayed.
bool add(const ChatMessage &message, Clock::time_point now)
Adds a message relayed by the server.
static constexpr std::size_t max_shown
Most lines shown at once: a new one pushes out the oldest.
Definition chat_log.hpp:26
std::chrono::steady_clock Clock
Clock of the lines.
Definition chat_log.hpp:22
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
std::string chat_rejection_text(std::uint8_t reason)
Sentence telling why a message was not sent.
The messages shown when a player joins or leaves the game.
Content of a ChatMessage.
Definition chat.hpp:38
A message about a player, shown for a few seconds.
Definition player_notices.hpp:19