Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
handler_switch.cpp File Reference
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
Include dependency graph for handler_switch.cpp:

Go to the source code of this file.

Typedefs

typedef websocketpp::server< websocketpp::config::asioserver
 

Functions

void custom_on_msg (server &s, connection_hdl hdl, server::message_ptr msg)
 
void default_on_msg (server &s, connection_hdl hdl, server::message_ptr msg)
 
int main ()
 

Typedef Documentation

◆ server

Function Documentation

◆ custom_on_msg()

void custom_on_msg ( server & s,
connection_hdl hdl,
server::message_ptr msg )

Definition at line 14 of file handler_switch.cpp.

14 {
15 std::cout << "Message sent to custom handler" << std::endl;
16}
Here is the caller graph for this function:

◆ default_on_msg()

void default_on_msg ( server & s,
connection_hdl hdl,
server::message_ptr msg )

Definition at line 18 of file handler_switch.cpp.

18 {
19 std::cout << "Message sent to default handler" << std::endl;
20
21 if (msg->get_payload() == "upgrade") {
22 // Upgrade our connection_hdl to a full connection_ptr
23 server::connection_ptr con = s.get_con_from_hdl(hdl);
24
25 // Change the on message handler for this connection only to
26 // custom_on_mesage
27 con->set_message_handler(bind(&custom_on_msg,ref(s),::_1,::_2));
28 std::cout << "Upgrading connection to custom handler" << std::endl;
29 }
30}
void custom_on_msg(server &s, connection_hdl hdl, server::message_ptr msg)
char * s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( void )

Definition at line 32 of file handler_switch.cpp.

32 {
33 server s;
34
35 s.set_message_handler(bind(&default_on_msg,ref(s),::_1,::_2));
36
37 s.init_asio();
38 s.listen(9002);
39 s.start_accept();
40
41 s.run();
42}
void set_message_handler(message_handler h)
Definition endpoint.hpp:322
void default_on_msg(server &s, connection_hdl hdl, server::message_ptr msg)
Here is the call graph for this function: