28 #ifndef WEBSOCKETPP_ENDPOINT_HPP 29 #define WEBSOCKETPP_ENDPOINT_HPP 41 template <
typename connection,
typename config>
92 :
m_alog(
config::alog_level, log::channel_type_hint::access)
93 ,
m_elog(
config::elog_level, log::channel_type_hint::error)
95 , m_open_handshake_timeout_dur(
config::timeout_open_handshake)
96 , m_close_handshake_timeout_dur(
config::timeout_close_handshake)
97 , m_pong_timeout_dur(
config::timeout_pong)
98 , m_max_message_size(
config::max_message_size)
99 , m_max_http_body_size(
config::max_http_body_size)
100 , m_is_server(p_is_server)
114 #ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 120 #endif // _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 122 #ifdef _WEBSOCKETPP_MOVE_SEMANTICS_ 127 ,
m_alog(std::move(o.m_alog))
128 ,
m_elog(std::move(o.m_elog))
129 , m_user_agent(std::move(o.m_user_agent))
130 , m_open_handler(std::move(o.m_open_handler))
132 , m_close_handler(std::move(o.m_close_handler))
133 , m_fail_handler(std::move(o.m_fail_handler))
134 , m_ping_handler(std::move(o.m_ping_handler))
135 , m_pong_handler(std::move(o.m_pong_handler))
136 , m_pong_timeout_handler(std::move(o.m_pong_timeout_handler))
137 , m_interrupt_handler(std::move(o.m_interrupt_handler))
138 , m_http_handler(std::move(o.m_http_handler))
139 , m_validate_handler(std::move(o.m_validate_handler))
140 , m_message_handler(std::move(o.m_message_handler))
142 , m_open_handshake_timeout_dur(o.m_open_handshake_timeout_dur)
143 , m_close_handshake_timeout_dur(o.m_close_handshake_timeout_dur)
144 , m_pong_timeout_dur(o.m_pong_timeout_dur)
145 , m_max_message_size(o.m_max_message_size)
146 , m_max_http_body_size(o.m_max_http_body_size)
148 , m_rng(std::move(o.m_rng))
149 , m_is_server(o.m_is_server)
152 #ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 155 #endif // _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 157 #endif // _WEBSOCKETPP_MOVE_SEMANTICS_ 170 scoped_lock_type guard(m_mutex);
197 scoped_lock_type guard(m_mutex);
279 scoped_lock_type guard(m_mutex);
284 scoped_lock_type guard(m_mutex);
289 scoped_lock_type guard(m_mutex);
294 scoped_lock_type guard(m_mutex);
299 scoped_lock_type guard(m_mutex);
304 scoped_lock_type guard(m_mutex);
305 m_pong_timeout_handler = h;
309 scoped_lock_type guard(m_mutex);
310 m_interrupt_handler = h;
314 scoped_lock_type guard(m_mutex);
319 scoped_lock_type guard(m_mutex);
320 m_validate_handler = h;
324 scoped_lock_type guard(m_mutex);
325 m_message_handler = h;
353 scoped_lock_type guard(m_mutex);
354 m_open_handshake_timeout_dur = dur;
378 scoped_lock_type guard(m_mutex);
379 m_close_handshake_timeout_dur = dur;
400 scoped_lock_type guard(m_mutex);
401 m_pong_timeout_dur = dur;
416 return m_max_message_size;
433 m_max_message_size = new_value;
450 return m_max_http_body_size;
467 m_max_http_body_size = new_value;
583 std::string
const & reason, lib::error_code & ec);
585 std::string
const & reason);
596 lib::error_code & ec);
617 lib::error_code & ec);
644 connection_ptr con = lib::static_pointer_cast<connection_type>(
668 std::string m_user_agent;
679 message_handler m_message_handler;
681 long m_open_handshake_timeout_dur;
682 long m_close_handshake_timeout_dur;
683 long m_pong_timeout_dur;
684 size_t m_max_message_size;
685 size_t m_max_http_body_size;
690 bool const m_is_server;
693 mutable mutex_type m_mutex;
700 #endif // WEBSOCKETPP_ENDPOINT_HPP void send_http_response(connection_hdl hdl, lib::error_code &ec)
Send deferred HTTP Response.
config::concurrency_type concurrency_type
Type of the concurrency component of this endpoint.
Asio based endpoint transport component.
void write(level, std::string const &)
Write a string message to the given channel.
uint16_t value
The type of a close code value.
void set_pong_timeout_handler(pong_timeout_handler h)
lib::error_code make_error_code(error::value e)
connection_type::termination_handler termination_handler
size_t get_max_message_size() const
Get default maximum message size.
bool is_server() const
Returns whether or not this endpoint is a server.
lib::function< void(connection_hdl)> close_handler
The type and function signature of a close handler.
void set_open_handler(open_handler h)
lib::function< void(connection_hdl)> open_handler
The type and function signature of an open handler.
void ping(connection_hdl hdl, std::string const &payload, lib::error_code &ec)
Send a ping to a specific connection.
lib::function< void(connection_hdl, std::string)> pong_timeout_handler
The type and function signature of a pong timeout handler.
lib::function< void(ptr)> termination_handler
lib::function< void(connection_hdl)> interrupt_handler
The type and function signature of an interrupt handler.
asio::connection< config > transport_con_type
Type of the connection transport component associated with this endpoint transport component...
config::rng_type rng_type
Type of RNG.
lib::function< bool(connection_hdl, std::string)> ping_handler
The type and function signature of a ping handler.
void set_close_handshake_timeout(long dur)
Set close handshake timeout.
lib::weak_ptr< type > weak_ptr
Type of a weak pointer to this connection.
Represents an individual WebSocket connection.
connection_type::message_ptr message_ptr
Type of message pointers that this endpoint uses.
void interrupt(connection_hdl hdl, lib::error_code &ec)
These functions act as adaptors to their counterparts in connection.
websocketpp::transport::asio::endpoint< transport_config > transport_type
connection_type::message_handler message_handler
Type of message_handler.
void set_open_handshake_timeout(long dur)
Set open handshake timeout.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
transport_con_type::ptr transport_con_ptr
Type of a shared pointer to the transport component of the connections that this endpoint creates...
alog_type & get_alog()
Get reference to access logger.
static const websocketpp::log::level alog_level
Default static access logging channels.
static char const user_agent[]
Default user agent string.
A fake lock guard implementation that does nothing.
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
concurrency_type::scoped_lock_type scoped_lock_type
Type of our concurrency policy's scoped lock object.
void set_ping_handler(ping_handler h)
A fake mutex implementation that does nothing.
void pause_reading(connection_hdl hdl, lib::error_code &ec)
Pause reading of new data (exception free)
lib::function< void(connection_hdl, message_ptr)> message_handler
void set_close_handler(close_handler h)
std::string get_user_agent() const
Returns the user agent string that this endpoint will use.
static level const devel
Development messages (warning: very chatty)
concurrency_type::mutex_type mutex_type
Type of our concurrency policy's mutex object.
void resume_reading(connection_hdl hdl, lib::error_code &ec)
Resume reading of new data (exception free)
lib::function< bool(connection_hdl)> validate_handler
The type and function signature of a validate handler.
message_type::ptr message_ptr
websocketpp::endpoint_base endpoint_base
User overridable Endpoint base class.
void set_max_http_body_size(size_t new_value)
Set maximum HTTP message body size.
void set_max_message_size(size_t new_value)
Set default maximum message size.
transport_type::transport_con_type transport_con_type
Type of the transport component of the connections that this endpoint creates.
config::alog_type alog_type
Type of access logger.
size_t get_max_http_body_size() const
Get maximum HTTP message body size.
config::transport_type transport_type
Type of the transport component of this endpoint.
connection_type::ptr connection_ptr
Shared pointer to connection_type.
static const websocketpp::log::level elog_level
Default static error logging channels.
endpoint< connection, config > type
An operation was attempted on a connection that did not exist or was already deleted.
lib::function< void(connection_hdl)> http_handler
The type and function signature of a http handler.
Thread safe stub "random" integer generator.
void set_pong_handler(pong_handler h)
void pong(connection_hdl hdl, std::string const &payload, lib::error_code &ec)
Send a pong to a specific connection.
void clear_error_channels(log::level channels)
Clear Error logging channels.
void set_access_channels(log::level channels)
Set Access logging channel.
Namespace for the WebSocket++ project.
endpoint(bool p_is_server)
void set_http_handler(http_handler h)
elog_type & get_elog()
Get reference to error logger.
Stub concurrency policy that implements the interface using no-ops.
config::elog_type elog_type
Type of error logger.
Creates and manages connections associated with a WebSocket endpoint.
void set_validate_handler(validate_handler h)
void clear_channels(level)
Dynamically disable the given list of channels.
connection_type::weak_ptr connection_weak_ptr
Weak pointer to connection type.
void set_fail_handler(fail_handler h)
void set_interrupt_handler(interrupt_handler h)
void init_logging(alog_type *a, elog_type *e)
Initialize logging.
lib::shared_ptr< type > ptr
Type of a shared pointer to this connection.
connection connection_type
Type of the connections that this endpoint creates.
void clear_access_channels(log::level channels)
Clear Access logging channels.
void set_error_channels(log::level channels)
Set Error logging channel.
void set_pong_timeout(long dur)
Set pong timeout.
lib::function< void(connection_hdl, std::string)> pong_handler
The type and function signature of a pong handler.
void close(connection_hdl hdl, close::status::value const code, std::string const &reason, lib::error_code &ec)
connection_ptr get_con_from_hdl(connection_hdl hdl)
Retrieves a connection_ptr from a connection_hdl (exception version)
void set_user_agent(std::string const &ua)
Sets the user agent string that this endpoint will use.
uint32_t level
Type of a channel package.
void set_message_handler(message_handler h)
void set_channels(level)
Dynamically enable the given list of channels.
Stub logger that ignores all input.
void send(connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
Create a message and add it to the outgoing send queue (exception free)
lib::function< void(connection_hdl)> fail_handler
The type and function signature of a fail handler.
connection_ptr create_connection()