RESTinio
connection_state_listener.hpp
Go to the documentation of this file.
1/*
2 * RESTinio
3 */
4
12#pragma once
13
16#include <restinio/variant.hpp>
17#include <restinio/tls_fwd.hpp>
18
19namespace restinio
20{
21
22namespace connection_state
23{
24
35class accepted_t final
36{
46
47public:
49 tls_socket_t * tls_socket )
50 : m_tls_socket{ tls_socket }
51 {}
52
60 bool
61 is_tls_connection() const noexcept { return nullptr != m_tls_socket; }
62
92 template< typename Lambda >
93 void
94 try_inspect_tls( Lambda && lambda ) const;
95
128 template< typename Lambda >
129 decltype(auto)
130 inspect_tls_or_throw( Lambda && lambda ) const;
131
169 template< typename Lambda, typename T >
170 T
171 inspect_tls_or_default( Lambda && lambda, T && default_value ) const;
172};
173
182class closed_t final
183{
184};
185
196{
197};
198
213
225{
229
230public :
233 connection_id_t conn_id,
235 cause_t cause )
236 : m_conn_id{ conn_id }
238 , m_cause{ cause }
239 {}
240
244 connection_id() const noexcept { return m_conn_id; }
245
250
252
258 cause_t
259 cause() const noexcept { return m_cause; }
260};
261
274{
275 // empty type by design.
276};
277
278} /* namespace connection_state */
279
280} /* namespace restinio */
281
Type of object that tells that new connection has been accepted.
decltype(auto) inspect_tls_or_throw(Lambda &&lambda) const
Calls the specified lambda-function if the accepted connection is a TLS-connection.
Definition: tls.hpp:109
RESTINIO_NODISCARD bool is_tls_connection() const noexcept
Checks if the accepted connection is a TLS-connection.
T inspect_tls_or_default(Lambda &&lambda, T &&default_value) const
Calls the specified lambda-function if the accepted connection is a TLS-connection.
Definition: tls.hpp:120
tls_socket_t * m_tls_socket
An optional pointer to TLS-related connection.
void try_inspect_tls(Lambda &&lambda) const
Calls the specified lambda-function if the accepted connection is a TLS-connection.
Definition: tls.hpp:101
Type of object that tells that the connection has been closed.
An object with info about connection to be passed to state listener.
RESTINIO_NODISCARD cause_t cause() const noexcept
Get the cause for the notification.
RESTINIO_NODISCARD connection_id_t connection_id() const noexcept
Get the connection id.
RESTINIO_NODISCARD endpoint_t remote_endpoint() const noexcept
Get the remote endpoint for the connection.
notice_t(connection_id_t conn_id, endpoint_t remote_endpoint, cause_t cause)
Initializing constructor.
Type of object that tells that the connection has been upgraded to WebSocket.
Socket adapter for asio::ssl::stream< asio::ip::tcp::socket >.
Definition: tls_socket.hpp:37
Detection of compiler version and absence of various features.
#define RESTINIO_NODISCARD
asio_ns::ip::tcp::endpoint endpoint_t
An alias for endpoint type from Asio.
std::uint64_t connection_id_t
Type for ID of connection.
Forward declarations for TLS-related things.
#define const
Definition: zconf.h:230