R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
login.hpp File Reference

TCP messages of the session (RFC section 3.2): encoding, decoding and name rules; those of the rooms are in rooms.hpp, those of the chat in chat.hpp, those of the scoreboard in scores.hpp. More...

#include <cstddef>
#include <cstdint>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>

Go to the source code of this file.

Classes

struct  rtype::LoginRequest
 Content of a LoginRequest. More...
 
struct  rtype::LoginAccepted
 Content of a LoginAccepted. More...
 

Namespaces

namespace  rtype
 R-Type game code, built on the Aegis2D engine.
 

Enumerations

enum class  rtype::TcpKind : std::uint8_t {
  rtype::LoginRequest = 1 , rtype::LoginAccepted = 2 , rtype::LoginRejected = 3 , rtype::Logout = 4 ,
  rtype::ListRooms = 5 , rtype::RoomList = 6 , rtype::CreateRoom = 7 , rtype::RoomCreated = 8 ,
  rtype::RoomRejected = 9 , rtype::JoinRoom = 10 , rtype::RoomJoined = 11 , rtype::JoinRejected = 12 ,
  rtype::LeaveRoom = 13 , rtype::SetReady = 14 , rtype::RoomPlayers = 15 , rtype::GameStart = 16 ,
  rtype::ChatSend = 17 , rtype::ChatMessage = 18 , rtype::ChatRejected = 19 , rtype::ListScores = 20 ,
  rtype::ScoreList = 21
}
 First byte of every TCP message: what it is. More...
 
enum class  rtype::LoginRejection : std::uint8_t {
  rtype::ServerFull = 1 , rtype::BadVersion = 2 , rtype::BadName = 3 , rtype::NameTaken = 4 ,
  rtype::GameStarted = 5 , rtype::Banned = 6
}
 Why a login is refused, the reason of LoginRejected. More...
 
enum class  rtype::LogoutReason : std::uint8_t {
  rtype::Left = 0 , rtype::Shutdown = 1 , rtype::TimedOut = 2 , rtype::ProtocolError = 3 ,
  rtype::RoomClosed = 4 , rtype::Kicked = 5 , rtype::Banned = 6
}
 Why a session ends, the reason of Logout. More...
 

Functions

std::string_view rtype::to_string (LoginRejection reason) noexcept
 Short name of a rejection, for logs.
 
bool rtype::valid_text (std::string_view text, std::size_t max_size) noexcept
 Tells whether a text is 1 to max_size bytes of valid UTF-8 without control characters, as player names and chat texts must be.
 
bool rtype::valid_player_name (std::string_view name) noexcept
 Tells whether a name follows the rules of LoginRequest.
 
std::optional< TcpKind > rtype::kind_of (std::span< const std::byte > message) noexcept
 Kind of a TCP message.
 
std::optional< LoginRequest > rtype::read_login_request (std::span< const std::byte > message)
 Reads a LoginRequest.
 
std::optional< LoginAccepted > rtype::read_login_accepted (std::span< const std::byte > message) noexcept
 Reads a LoginAccepted.
 
std::optional< std::uint8_t > rtype::read_login_rejected (std::span< const std::byte > message) noexcept
 Reads a LoginRejected.
 
std::optional< std::uint8_t > rtype::read_logout (std::span< const std::byte > message) noexcept
 Reads a Logout.
 
std::vector< std::byte > rtype::write_login_request (const LoginRequest &request)
 Encodes a LoginRequest.
 
std::vector< std::byte > rtype::write_login_accepted (const LoginAccepted &accepted)
 Encodes a LoginAccepted.
 
std::vector< std::byte > rtype::write_login_rejected (LoginRejection reason)
 Encodes a LoginRejected.
 
std::vector< std::byte > rtype::write_logout (LogoutReason reason)
 Encodes a Logout.
 

Variables

constexpr std::uint8_t rtype::protocol_version = 1
 Protocol version the server speaks, in LoginRequest and in the UDP header.
 
constexpr std::size_t rtype::max_name_size = 16
 Longest player name, in bytes of UTF-8.
 

Detailed Description

TCP messages of the session (RFC section 3.2): encoding, decoding and name rules; those of the rooms are in rooms.hpp, those of the chat in chat.hpp, those of the scoreboard in scores.hpp.