|
| | SessionTable () |
| | Creates an empty table drawing tokens from the system's random source.
|
| |
| | SessionTable (std::uint64_t seed) noexcept |
| | Creates an empty table drawing tokens from a seed, for tests.
|
| |
| std::variant< Session, LoginRejection > | login (const LoginRequest &request) |
| | Decides a login and opens its session if it is accepted.
|
| |
| BindResult | bind (std::uint32_t token, const aegis2d::net::Endpoint &endpoint) |
| | Binds the source endpoint of a Connect to the session of its token.
|
| |
| bool | end (std::uint32_t token) noexcept |
| | Ends a session and frees its place, name and endpoint; the last one of its room ends the room.
|
| |
| std::variant< std::uint8_t, JoinRejection > | join (std::uint32_t token, std::uint32_t room) |
| | Moves a session out of game to another room in use (JoinRoom, RFC 3.7).
|
| |
| std::optional< std::uint32_t > | leave (std::uint32_t token) |
| | Moves a session out of game from its room to the lobby (LeaveRoom).
|
| |
| bool | set_ready (std::uint32_t token, bool ready) noexcept |
| | Sets whether a session out of game, in a room, is ready (SetReady).
|
| |
| std::vector< Session > | members (std::uint32_t room) const |
| | The sessions of a room.
|
| |
| const Session * | find (std::uint32_t token) const noexcept |
| | Finds a session.
|
| |
| const Session * | find (const aegis2d::net::Endpoint &endpoint) const noexcept |
| | Finds the session bound to an endpoint.
|
| |
| std::size_t | size () const noexcept |
| | Number of open sessions, those of the lobby included.
|
| |
| void | set_rooms (std::uint32_t rooms) |
| | Sets how many rooms the sessions are spread over, tuning::max_players in each at most.
|
| |
| std::uint32_t | rooms () const noexcept |
| | Number of rooms the sessions are spread over.
|
| |
| std::variant< std::uint8_t, RoomRejection > | create_room (const CreateRoomRequest &request) |
| | Creates a room, empty, for the next logins (CreateRoom, RFC section 3.6).
|
| |
| void | set_waves (std::vector< std::string > names) |
| | Sets the waves files a room may be created with, besides the server's own.
|
| |
| std::optional< RoomRules > | rules (std::uint32_t room) const |
| | The rules of a room in use.
|
| |
| std::vector< RoomRecord > | list_rooms () const |
| | The rooms in use, by number, as a RoomList describes them.
|
| |
The sessions of the server and the rooms they are in.
Decides each login (version, name, free place), puts it in a room, draws the tokens, moves the sessions between the rooms and the lobby, binds each session to the UDP endpoint of its Connect, and forgets it when it ends. It also keeps the rooms in use, with their name and size (RFC section 3.6): a room is in use from its creation, by create_room() or for a login that found no free place, until its last session leaves or ends. It does not touch sockets, so it is tested alone. Not thread-safe: use it from the network thread only.
Creates a room, empty, for the next logins (CreateRoom, RFC section 3.6).
Checked in this order: the name, by the rules of player names (valid_player_name()), the size, the lives, the difficulty, the waves (empty, or one of set_waves()), the friendly fire, a room not in use. The room takes the lowest number of those.
- Parameters
-
| request | Name and most players of the room. |
- Returns
- Its number, or why it is not created.
Decides a login and opens its session if it is accepted.
Checked in this order: the version, the name, a free place, the name not used by another player of any room. The session goes to the first room in use with a free place, so a room fills before the next gets players, or else to a new room for tuning::max_players named Room <number + 1>; the server takes rooms() times tuning::max_players sessions, those of the lobby included. It takes the lowest free player number of its room, and a new random token, never 0 and never the token of another session.
- Parameters
-
| request | Version and name received. |
- Returns
- The new session, or why the login is refused.