void
ServerAcceptWebHelper::on_message(websocketpp::connection_hdl hdl, server::message_ptr msg)
{
	if (msg->get_opcode() == websocketpp::frame::opcode::BINARY) {
		SessionMap::iterator pos = m_sessionMap.find(hdl);
		if (pos != m_sessionMap.end()) {
			boost::shared_ptr<SessionData> tmpSession = pos->second.lock();
			if (tmpSession) {
				tmpSession->GetReceiveBuffer().HandleMessage(tmpSession, msg->get_payload());
			}
		}
	}
}
Esempio n. 2
0
void messageReceived(Server* server, websocketpp::connection_hdl hdl, Server::message_ptr message)
{
    messageCount++;
    std::string payload = message->get_payload();

#ifndef NDEBUG
    std::cout << "received: " << messageCount << std::endl;
#endif

    // killServer message
    if (payload == "killServer") {
        std::cout << "killServer" << std::endl;
        server->stop_listening();
        return;
    }

    // send received message back
    try {
        server->send(hdl, message->get_payload(), message->get_opcode());
    } catch (const websocketpp::lib::error_code& e) {
        std::cout << "send failed: " << e << ":" << e.message() << std::endl;
    }
}
Esempio n. 3
0
 void echo_handler(websocketpp::connection_hdl hdl, server::message_ptr msg) {
     // write a new message
     m_endpoint.send(hdl, msg->get_payload(), msg->get_opcode());
 }
Esempio n. 4
0
    void echo_handler(websocketpp::connection_hdl hdl, server::message_ptr msg) {
        // write a new message
		std::string str = msg->get_payload();
		printf("\nrec: %s\n",str.c_str());
        m_endpoint.send(hdl, msg->get_payload(), msg->get_opcode());
    }