irccd
3.0.3
|
Abstract transport server class. More...
#include <transport_server.hpp>
Public Types | |
using | client_set = std::unordered_set< std::shared_ptr< transport_client > > |
using | accept_handler = std::function< void(std::error_code, std::shared_ptr< transport_client >)> |
Public Member Functions | |
transport_server (std::unique_ptr< acceptor > acceptor) noexcept | |
auto | get_clients () const noexcept -> const client_set & |
auto | get_clients () noexcept -> client_set & |
auto | get_password () const noexcept -> const std::string & |
void | set_password (std::string password) noexcept |
void | accept (accept_handler handler) |
Abstract transport server class.
The transport_server class is an abstract interface that waits for clients to connect and store them locally. It does not know the underlying implementation so derived classes may be implemented in any shape of form.
As only constraint the implementation must provide an asynchronous operation to avoid blocking the daemon.
The derived class only have to implement accept function which is only responsible of getting a client ready for I/O (receiving and sending), the transport_server does authentication and greeting by itself.
The connection procedure looks like this:
Each client has a reference to its parent, since operations are asynchronous, they maintain their lifetime by themselve to update the parent list on errors.
See the following diagram:
using irccd::daemon::transport_server::accept_handler = std::function<void (std::error_code, std::shared_ptr<transport_client>)> |
Accept completion handler.
using irccd::daemon::transport_server::client_set = std::unordered_set<std::shared_ptr<transport_client> > |
Set of clients.
|
noexcept |
Constructor.
acceptor | the stream acceptor |
void irccd::daemon::transport_server::accept | ( | accept_handler | handler | ) |
Accept a client.
Also perform greetings and authentication under the hood. On success, the client is added into the server and is ready to use.
handler | the completion handler |
|
noexcept |
Get the clients.
|
noexcept |
Overloaded function.
|
noexcept |
Get the current password, empty string means no password.
|
noexcept |
Set an optional password, empty string means no password.
password | the password |