Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
scratch_server.cpp File Reference
Include dependency graph for scratch_server.cpp:

Go to the source code of this file.

Classes

struct  deflate_config
 
struct  deflate_config::transport_config
 
struct  deflate_config::permessage_deflate_config
 permessage_compress extension More...
 

Typedefs

typedef websocketpp::server< deflate_configserver
 

Functions

void on_message (server *s, websocketpp::connection_hdl hdl, message_ptr msg)
 
int main (int argc, char *argv[])
 

Typedef Documentation

◆ server

Definition at line 51 of file scratch_server.cpp.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 69 of file scratch_server.cpp.

69 {
70 // Create a server endpoint
71 server echo_server;
72
73 try {
74 // Set logging settings
75 if (argc > 1 && std::string(argv[1]) == "-d") {
78 } else {
81 }
82
83 // Initialize ASIO
84 echo_server.init_asio();
85
86 // Register our message handler
87 using websocketpp::lib::placeholders::_1;
88 using websocketpp::lib::placeholders::_2;
89 echo_server.set_message_handler(bind(&on_message,&echo_server,_1,_2));
90
91 // Listen on port 9002
92 echo_server.listen(9002);
93
94 // Start the server accept loop
95 echo_server.start_accept();
96
97 // Start the ASIO io_service run loop
98 echo_server.run();
99 } catch (const std::exception & e) {
100 std::cout << e.what() << std::endl;
101 } catch (websocketpp::lib::error_code e) {
102 std::cout << e.message() << std::endl;
103 } catch (...) {
104 std::cout << "other exception" << std::endl;
105 }
106}
void set_message_handler(message_handler h)
Definition endpoint.hpp:322
void set_access_channels(log::level channels)
Set Access logging channel.
Definition endpoint.hpp:220
void set_error_channels(log::level channels)
Set Error logging channel.
Definition endpoint.hpp:242
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
char ** argv
void on_message(server *s, websocketpp::connection_hdl hdl, message_ptr msg)
static level const none
Special aggregate value representing "no levels".
Definition levels.hpp:114
static level const all
Special aggregate value representing "all levels".
Definition levels.hpp:152
static level const all
Special aggregate value representing "all levels".
Definition levels.hpp:80
static level const none
Special aggregate value representing "no levels".
Definition levels.hpp:61
Here is the call graph for this function:

◆ on_message()

void on_message ( server * s,
websocketpp::connection_hdl hdl,
message_ptr msg )

Definition at line 56 of file scratch_server.cpp.

56 {
57 /*std::cout << "on_message called with hdl: " << hdl.lock().get()
58 << " and message (" << msg->get_payload().size() << "): " << msg->get_payload()
59 << std::endl;
60 */
61 try {
62 s->send(hdl, msg->get_payload(), msg->get_opcode());
63 } catch (const websocketpp::lib::error_code& e) {
64 std::cout << "Echo failed because: " << e
65 << "(" << e.message() << ")" << std::endl;
66 }
67}
char * s
Here is the caller graph for this function: