Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sip_client.cpp File Reference
#include <condition_variable>
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
#include <iostream>
#include <boost/thread/thread.hpp>
Include dependency graph for sip_client.cpp:

Go to the source code of this file.

Typedefs

typedef websocketpp::client< websocketpp::config::asio_clientclient
 

Functions

void on_open (client *c, websocketpp::connection_hdl hdl)
 
void on_message (client *c, websocketpp::connection_hdl hdl, message_ptr msg)
 
int main (int argc, char *argv[])
 

Variables

client sip_client
 
bool received
 

Typedef Documentation

◆ client

Function Documentation

◆ main()

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

Definition at line 44 of file sip_client.cpp.

44 {
45
46 std::string uri = "ws://localhost:9001";
47
48 if (argc == 2) {
49 uri = argv[1];
50 }
51
52 try {
53 // We expect there to be a lot of errors, so suppress them
56
57 // Initialize ASIO
58 sip_client.init_asio();
59
60 // Register our handlers
63
64 websocketpp::lib::error_code ec;
66
67 // Specify the SIP subprotocol:
68 con->add_subprotocol("sip");
69
71
72 // Start the ASIO io_service run loop
73 sip_client.run();
74
75 while(!received) {
76 boost::this_thread::sleep(boost::posix_time::milliseconds(100));
77 }
78
79 std::cout << "done" << std::endl;
80
81 } catch (websocketpp::exception const & e) {
82 std::cout << e.what() << std::endl;
83 }
84}
connection_ptr connect(connection_ptr con)
Begin the connection process for the given connection.
connection_ptr get_connection(uri_ptr location, lib::error_code &ec)
Get a new connection.
void set_message_handler(message_handler h)
Definition endpoint.hpp:322
void clear_access_channels(log::level channels)
Clear Access logging channels.
Definition endpoint.hpp:231
void set_open_handler(open_handler h)
Definition endpoint.hpp:277
void clear_error_channels(log::level channels)
Clear Error logging channels.
Definition endpoint.hpp:253
virtual char const * what() const
Definition error.hpp:263
char ** argv
client sip_client
bool received
void on_message(client *c, websocketpp::connection_hdl hdl, message_ptr msg)
void on_open(client *c, websocketpp::connection_hdl hdl)
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
Here is the call graph for this function:

◆ on_message()

void on_message ( client * c,
websocketpp::connection_hdl hdl,
message_ptr msg )

Definition at line 36 of file sip_client.cpp.

36 {
38
39 std::cout << "Received a reply:" << std::endl;
40 fwrite(msg->get_payload().c_str(), msg->get_payload().size(), 1, stdout);
41 received=true;
42}
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
Definition endpoint.hpp:643
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_open()

void on_open ( client * c,
websocketpp::connection_hdl hdl )

Definition at line 26 of file sip_client.cpp.

26 {
27 // now it is safe to use the connection
28 std::cout << "connection ready" << std::endl;
29
30 received=false;
31 // Send a SIP OPTIONS message to the server:
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";
34}
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)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ received

bool received

Definition at line 24 of file sip_client.cpp.

◆ sip_client

client sip_client

Definition at line 21 of file sip_client.cpp.