60[[nodiscard]] std::optional<ChatRejection>
check_chat_text(std::string_view text)
noexcept;
66[[nodiscard]] std::optional<std::string>
read_chat_send(std::span<const std::byte> message);
72[[nodiscard]] std::optional<ChatMessage>
read_chat_message(std::span<const std::byte> message);
78[[nodiscard]] std::optional<std::uint8_t>
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
constexpr std::uint8_t lobby_player
player of a ChatMessage whose sender is in the lobby, with no player number.
Definition chat.hpp:18
constexpr std::size_t max_chat_size
Longest chat text, in bytes of UTF-8.
Definition chat.hpp:15
std::vector< std::byte > write_chat_message(const ChatMessage &message)
Encodes a ChatMessage.
std::optional< std::uint8_t > read_chat_rejected(std::span< const std::byte > message) noexcept
Reads a ChatRejected.
constexpr std::string_view server_name
name of a ChatMessage of the server itself.
Definition chat.hpp:25
constexpr std::uint8_t server_player
player of a ChatMessage of the server itself, such as its administrator's say: no player has it (RFC ...
Definition chat.hpp:22
std::optional< ChatRejection > check_chat_text(std::string_view text) noexcept
Checks a text against the rules of ChatSend, the length first.
std::vector< std::byte > write_chat_send(std::string_view text)
Encodes a ChatSend.
std::optional< std::string > read_chat_send(std::span< const std::byte > message)
Reads a ChatSend.
std::optional< ChatMessage > read_chat_message(std::span< const std::byte > message)
Reads a ChatMessage.
std::string_view to_string(ChatRejection reason) noexcept
Short name of a rejection, for logs.
std::vector< std::byte > write_chat_rejected(ChatRejection reason)
Encodes a ChatRejected.
ChatRejection
Why a chat message is not relayed, the reason of ChatRejected.
Definition chat.hpp:28
@ TooLong
The text is longer than max_chat_size bytes.
@ BadText
The text is empty, not UTF-8 or has control characters.
@ TooFast
The sender is over the rate: the message is a flood.
Content of a ChatMessage.
Definition chat.hpp:38
std::string name
Name of the sender, as received: see valid_player_name().
Definition chat.hpp:42
bool operator==(const ChatMessage &) const =default
Field-by-field equality.
std::string text
Text, as received: see check_chat_text().
Definition chat.hpp:44
std::uint8_t player
Number of the sender in its room, or lobby_player.
Definition chat.hpp:40