|
Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
|
Manages active HTTP connections. More...
#include <ConnectionManager.hpp>

Public Member Functions | |
| ConnectionManager (network::Proactor &proactor, const routing::Router &router, concurrency::ThreadPool &thread_pool, TimerManager &timer_manager, size_t max_body_size, network::TlsContext *tls_context=nullptr) | |
| Constructs a ConnectionManager. | |
| ~ConnectionManager () | |
| void | set_timeouts (const ConnectionTimeouts &timeouts) |
| Sets the timeouts applied to connections accepted from now on. | |
| void | set_limits (const ConnectionLimits &limits) |
| void | set_on_removed (std::function< void()> callback) |
| Called once for each connection removed (from the thread removing it). | |
| void | ping_websockets () |
| Event-loop thread: pings every WebSocket connection. | |
| void | add_connection (network::Socket socket, const std::string &client_ip) |
| Adds a new connection to the manager. | |
| void | remove_connection (int fd) |
| Removes a connection by file descriptor. | |
| size_t | get_connection_count () const |
| Gets the current number of active connections. | |
| void | notify_shutdown () |
| void | mark_shutting_down () |
| bool | shutting_down () const |
Private Attributes | |
| std::atomic< bool > | shutting_down_ {false} |
| network::Proactor & | proactor_ |
| const routing::Router & | router_ |
| concurrency::ThreadPool & | thread_pool_ |
| TimerManager & | timer_manager_ |
| ConnectionTimeouts | timeouts_ |
| ConnectionLimits | limits_ |
| std::unordered_map< int, std::shared_ptr< Connection > > | connections_ |
| std::mutex | map_mutex_ |
| std::function< void()> | on_removed_ |
| size_t | max_body_size_ |
| network::TlsContext * | tls_context_ |
Manages active HTTP connections.
| orbit::server::ConnectionManager::ConnectionManager | ( | network::Proactor & | proactor, |
| const routing::Router & | router, | ||
| concurrency::ThreadPool & | thread_pool, | ||
| TimerManager & | timer_manager, | ||
| size_t | max_body_size, | ||
| network::TlsContext * | tls_context = nullptr |
||
| ) |
Constructs a ConnectionManager.
| proactor | The proactor for I/O. |
| router | The router. |
| thread_pool | The thread pool. |
| timer_manager | The timer manager. |
| max_body_size | The maximum body size allowed. |
| tls_context | The TLS context (optional). |
| orbit::server::ConnectionManager::~ConnectionManager | ( | ) |
Connections still open (the server is going away) are closed for anyone still holding one as a ResponseWriter.
| void orbit::server::ConnectionManager::add_connection | ( | network::Socket | socket, |
| const std::string & | client_ip | ||
| ) |
Adds a new connection to the manager.
| socket | The connection socket. |
| client_ip | The client's IP address. |
| size_t orbit::server::ConnectionManager::get_connection_count | ( | ) | const |
Gets the current number of active connections.
|
inline |
Any thread: set as soon as shutdown is requested, before the event loop gets to notify_shutdown(), so responses sent in between already carry "Connection: close".
| void orbit::server::ConnectionManager::notify_shutdown | ( | ) |
Event-loop thread: asks every connection to finish up (see Connection::on_server_shutdown). Called repeatedly while draining.
| void orbit::server::ConnectionManager::ping_websockets | ( | ) |
Event-loop thread: pings every WebSocket connection.
| void orbit::server::ConnectionManager::remove_connection | ( | int | fd | ) |
Removes a connection by file descriptor.
| fd | The file descriptor. |
|
inline |
|
inline |
Called once for each connection removed (from the thread removing it).
|
inline |
Sets the timeouts applied to connections accepted from now on.
|
inline |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |