void on_open(client* c, websocketpp::connection_hdl hdl) { // now it is safe to use the connection std::cout << "connection ready" << std::endl; received=false; // Send a SIP OPTIONS message to the server: std::string SIP_msg="OPTIONS sip:[email protected] SIP/2.0\r\nVia: SIP/2.0/WS df7jal23ls0d.invalid;rport;branch=z9hG4bKhjhs8ass877\r\nMax-Forwards: 70\r\nTo: <sip:[email protected]>\r\nFrom: Alice <sip:[email protected]>;tag=1928301774\r\nCall-ID: a84b4c76e66710\r\nCSeq: 63104 OPTIONS\r\nContact: <sip:[email protected]>\r\nAccept: application/sdp\r\nContent-Length: 0\r\n\r\n"; sip_client.send(hdl, SIP_msg.c_str(), websocketpp::frame::opcode::text); }
void echo(int messages, int factor) { for (int j = 0; j < factor; j++) { for (int i = 0; i < messages; i++) { clientIO.send(connectionVector[rand() % connectionVector.size()], ECHO_MESSAGE, websocketpp::frame::opcode::value::BINARY); sent++; } } }
void echoMessage(int i) { echoed = false; clientIO.send(heavyConnections[i], ECHO_MESSAGE, websocketpp::frame::opcode::value::TEXT); while(!echoed) { clientIO.run_one(); } }
void operator()(client& c, std::string message) { std::smatch match; std::regex expression("^:(\\S+) PRIVMSG (\\S+)+ :!alice$"); std::regex_search(message, match, expression); if(match.size()) { std::string sender = match[2]; std::string message = g.getSentence(); c.send("PRIVMSG " + sender + " :" + message); } }
void client::onPing(client& c, std::string message) { std::smatch match; std::regex e("PING :(.*)"); std::regex_match(message, match, e); if(match.size()) { std::string pong("PONG :"); pong += match[1]; c.send(pong); } }