89using websocketpp::lib::placeholders::_1;
90using websocketpp::lib::placeholders::_2;
91using websocketpp::lib::bind;
104 std::string res = con->get_request_body();
106 std::stringstream ss;
107 ss <<
"got HTTP request with " << res.size() <<
" bytes of body data.";
109 con->set_body(ss.str());
116 std::cout <<
"Fail handler: " << con->get_ec() <<
" " << con->get_ec().message() << std::endl;
120 std::cout <<
"Close handler" << std::endl;
125 std::cout <<
"on_message called with hdl: " << hdl.lock().get()
126 <<
" and message: " << msg->get_payload()
130 s->send(hdl, msg->get_payload(), msg->get_opcode());
131 }
catch (
const websocketpp::lib::error_code& e) {
132 std::cout <<
"Echo failed because: " << e
133 <<
"(" << e.message() <<
")" << std::endl;
147 echo_server.init_asio();
148 echo_server.set_reuse_addr(
true);
160 echo_server.listen(9012);
167 }
catch (
const std::exception & e) {
168 std::cout << e.what() << std::endl;
169 }
catch (websocketpp::lib::error_code e) {
170 std::cout << e.message() << std::endl;
172 std::cout <<
"other exception" << std::endl;
void set_fail_handler(fail_handler h)
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
void set_message_handler(message_handler h)
void clear_access_channels(log::level channels)
Clear Access logging channels.
void set_http_handler(http_handler h)
void set_access_channels(log::level channels)
Set Access logging channel.
connection_type::message_ptr message_ptr
void set_close_handler(close_handler h)
void set_validate_handler(validate_handler h)
Server endpoint role based on the given config.
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
connection_type::ptr connection_ptr
Basic ASIO endpoint socket component.
Asio based endpoint transport component.
websocketpp::config::asio_tls_client::message_type::ptr message_ptr
websocketpp::server< debug_custom > server
server::message_ptr message_ptr
void on_fail(server *s, websocketpp::connection_hdl hdl)
bool validate(server *, websocketpp::connection_hdl)
void on_message(server *s, websocketpp::connection_hdl hdl, message_ptr msg)
void on_close(websocketpp::connection_hdl)
void on_http(server *s, websocketpp::connection_hdl hdl)
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
websocketpp::transport::asio::basic_socket::endpoint socket_type
type::alog_type alog_type
type::concurrency_type concurrency_type
type::request_type request_type
type::elog_type elog_type
type::response_type response_type
static const long timeout_open_handshake
base::concurrency_type concurrency_type
base::elog_type elog_type
base::response_type response_type
base::con_msg_manager_type con_msg_manager_type
base::alog_type alog_type
Custom Logging policies.
base::message_type message_type
websocketpp::transport::asio::endpoint< transport_config > transport_type
base::request_type request_type
base::endpoint_msg_manager_type endpoint_msg_manager_type
Client/Server debug config with asio transport and TLS disabled.
static level const all
Special aggregate value representing "all levels".
static level const frame_payload
One line per frame, includes the full message payload (warning: chatty)