34 using websocketpp::lib::placeholders::_1;
35 using websocketpp::lib::placeholders::_2;
36 using websocketpp::lib::bind;
42 std::cout <<
"on_message called with hdl: " << hdl.lock().get()
43 <<
" and message: " << msg->get_payload()
48 if (msg->get_payload() ==
"stop-listening") {
54 s->
send(hdl, msg->get_payload(), msg->get_opcode());
55 }
catch (websocketpp::lib::error_code
const & e) {
56 std::cout <<
"Echo failed because: " << e
57 <<
"(" << e.message() <<
")" << std::endl;
62 asio::io_service service;
static level const all
Special aggregate value representing "all levels".
connection_type::message_ptr message_ptr
Type of message pointers that this endpoint uses.
static level const frame_payload
One line per frame, includes the full message payload (warning: chatty)
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
void init_asio(io_service_ptr ptr, lib::error_code &ec)
initialize asio transport with external io_service (exception free)
void on_message(ws_echo_server *s, websocketpp::connection_hdl hdl, ws_echo_server::message_ptr msg)
websocketpp::server< websocketpp::config::asio > ws_echo_server
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
void set_access_channels(log::level channels)
Set Access logging channel.
void stop_listening(lib::error_code &ec)
Stop listening (exception free)
void clear_access_channels(log::level channels)
Clear Access logging channels.
void listen(lib::asio::ip::tcp::endpoint const &ep, lib::error_code &ec)
Set up endpoint for listening manually (exception free)
void set_message_handler(message_handler h)
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)