1 #include <condition_variable> 9 #include <boost/thread/thread.hpp> 13 using websocketpp::lib::placeholders::_1;
14 using websocketpp::lib::placeholders::_2;
15 using websocketpp::lib::bind;
28 std::cout <<
"connection ready" << std::endl;
32 std::string SIP_msg=
"OPTIONS sip:carol@chicago.com SIP/2.0\r\nVia: SIP/2.0/WS df7jal23ls0d.invalid;rport;branch=z9hG4bKhjhs8ass877\r\nMax-Forwards: 70\r\nTo: <sip:carol@chicago.com>\r\nFrom: Alice <sip:alice@atlanta.com>;tag=1928301774\r\nCall-ID: a84b4c76e66710\r\nCSeq: 63104 OPTIONS\r\nContact: <sip:alice@pc33.atlanta.com>\r\nAccept: application/sdp\r\nContent-Length: 0\r\n\r\n";
39 std::cout <<
"Received a reply:" << std::endl;
40 fwrite(msg->get_payload().c_str(), msg->get_payload().size(), 1, stdout);
44 int main(
int argc,
char* argv[]) {
46 std::string uri =
"ws://localhost:9001";
64 websocketpp::lib::error_code ec;
68 con->add_subprotocol(
"sip");
79 std::cout <<
"done" << std::endl;
82 std::cout << e.
what() << std::endl;
static level const all
Special aggregate value representing "all levels".
connection_type::ptr connection_ptr
Type of a shared pointer to the connections this server will create.
websocketpp::config::asio_tls_client::message_type::ptr message_ptr
websocketpp::client< websocketpp::config::asio_client > client
void set_open_handler(open_handler h)
websocketpp::config::asio_client::message_type::ptr message_ptr
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
connection_ptr connect(connection_ptr con)
Begin the connection process for the given connection.
void on_open(client *c, websocketpp::connection_hdl hdl)
void init_asio(io_service_ptr ptr, lib::error_code &ec)
initialize asio transport with external io_service (exception free)
lib::shared_ptr< message > ptr
void clear_error_channels(log::level channels)
Clear Error logging channels.
int main(int argc, char *argv[])
void clear_access_channels(log::level channels)
Clear Access logging channels.
void on_message(client *c, websocketpp::connection_hdl hdl, message_ptr msg)
std::size_t run()
wraps the run method of the internal io_service object
void set_message_handler(message_handler h)
virtual char const * what() const
static level const all
Special aggregate value representing "all levels".
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)
connection_ptr get_connection(uri_ptr location, lib::error_code &ec)
Get a new connection.
boost::chrono::milliseconds milliseconds