28 #ifndef WEBSOCKETPP_SERVER_ENDPOINT_HPP 29 #define WEBSOCKETPP_SERVER_ENDPOINT_HPP 31 #include <websocketpp/endpoint.hpp> 33 #include <websocketpp/logger/levels.hpp> 35 #include <websocketpp/common/system_error.hpp> 43 template <
typename config>
67 friend class connection<
config>;
69 explicit server() : endpoint_type(
true)
71 endpoint_type::m_alog->write(log::alevel::devel,
"server constructor");
77 #ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 85 #ifdef _WEBSOCKETPP_MOVE_SEMANTICS_ 89 #ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_ 107 return endpoint_type::create_connection();
123 ec = error::make_error_code(error::async_accept_not_listening);
127 ec = lib::error_code();
128 connection_ptr con = get_connection();
131 ec = error::make_error_code(error::con_creation_failed);
135 transport_type::async_accept(
136 lib::static_pointer_cast<transport_con_type>(con),
137 lib::bind(&type::handle_accept,
this,con,lib::placeholders::_1),
144 con->terminate(lib::error_code());
170 if (ec == error::operation_canceled) {
171 endpoint_type::m_elog->write(log::elevel::info,
172 "handle_accept error: "+ec.message());
174 endpoint_type::m_elog->write(log::elevel::rerror,
175 "handle_accept error: "+ec.message());
181 lib::error_code start_ec;
182 start_accept(start_ec);
183 if (start_ec == error::async_accept_not_listening) {
184 endpoint_type::m_elog->write(log::elevel::info,
185 "Stopping acceptance of new connections because the underlying transport is no longer listening.");
186 }
else if (start_ec) {
187 endpoint_type::m_elog->write(log::elevel::rerror,
188 "Restarting async_accept loop failed: "+ec.message());
config::transport_type transport_type
Type of the endpoint transport component.
transport_con_type::ptr transport_con_ptr
Type of a shared pointer to the connection transport component.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
config::concurrency_type concurrency_type
Type of the endpoint concurrency component.
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
void handle_accept(connection_ptr con, lib::error_code const &ec)
Handler callback for start_accept.
void start_accept()
Starts the server's async connection acceptance loop.
endpoint< connection_type, config > endpoint_type
Type of the endpoint component of this server.
connection_ptr get_connection()
Create and initialize a new connection.
connection< config > connection_type
Type of the connections this server will create.
connection_type::ptr connection_ptr
Type of a shared pointer to the connections this server will create.
transport_type::transport_con_type transport_con_type
Type of the connection transport component.
server< config > type
Type of this endpoint.