58 static bool const enable_multithreading =
true;
78 using websocketpp::lib::placeholders::_1;
79 using websocketpp::lib::placeholders::_2;
80 using websocketpp::lib::bind;
87 s->
send(hdl, msg->get_payload(), msg->get_opcode());
91 boost::asio::ip::tcp::no_delay option(
true);
95 int main(
int argc,
char * argv[]) {
100 size_t num_threads = 1;
103 port = atoi(argv[1]);
104 num_threads = atoi(argv[2]);
113 testee_server.init_asio();
114 testee_server.set_reuse_addr(
true);
118 testee_server.set_socket_init_handler(bind(&
on_socket_init,::_1,::_2));
121 testee_server.set_listen_backlog(8192);
122 testee_server.listen(port);
128 if (num_threads == 1) {
131 typedef websocketpp::lib::shared_ptr<websocketpp::lib::thread> thread_ptr;
132 std::vector<thread_ptr> ts;
133 for (
size_t i = 0; i < num_threads; i++) {
134 ts.push_back(websocketpp::lib::make_shared<websocketpp::lib::thread>(&server::run, &testee_server));
137 for (
size_t i = 0; i < num_threads; i++) {
143 std::cout <<
"exception: " << e.
what() << std::endl;
static level const all
Special aggregate value representing "all levels".
core::alog_type alog_type
Asio based endpoint transport component.
websocketpp::config::asio_tls_client::message_type::ptr message_ptr
static level const none
Special aggregate value representing "no levels".
websocketpp::server< testee_config > server
core::con_msg_manager_type con_msg_manager_type
Concurrency policy that uses std::mutex / boost::mutex.
connection_type::message_ptr message_ptr
Type of message pointers that this endpoint uses.
static bool const enable_multithreading
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
websocketpp::config::asio core
permessage_compress extension
Stores, parses, and manipulates HTTP responses.
server::message_ptr message_ptr
core::alog_type alog_type
core::response_type response_type
core::endpoint_msg_manager_type endpoint_msg_manager_type
static level const none
Special aggregate value representing "no levels".
core::request_type request_type
Basic logger that outputs to an ostream.
Stub for user supplied base class.
void on_socket_init(websocketpp::connection_hdl, boost::asio::ip::tcp::socket &s)
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
Server endpoint role based on the given config.
Thread safe stub "random" integer generator.
static const websocketpp::log::level alog_level
void clear_error_channels(log::level channels)
Clear Error logging channels.
Represents a buffer for a single WebSocket message.
core::endpoint_base endpoint_base
void on_message(server *s, websocketpp::connection_hdl hdl, message_ptr msg)
core::elog_type elog_type
core::concurrency_type concurrency_type
websocketpp::extensions::permessage_deflate::enabled< permessage_deflate_config > permessage_deflate_type
void clear_access_channels(log::level channels)
Clear Access logging channels.
Stores, parses, and manipulates HTTP requests.
static const websocketpp::log::level elog_level
Catch-all error for socket component errors that don't fit in other categories.
core::elog_type elog_type
core::concurrency_type concurrency_type
core::response_type response_type
core::request_type request_type
int main(int argc, char *argv[])
uint32_t level
Type of a channel package.
void set_message_handler(message_handler h)
core::message_type message_type
virtual char const * what() const
A connection message manager that allocates a new message for each request.
An endpoint message manager that allocates a new manager for each connection.
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)
websocketpp::transport::asio::endpoint< transport_config > transport_type
Server config with asio transport and TLS disabled.