Beispiel #1
0
void endpoint<connection,config>::pong(connection_hdl hdl, std::string const &
    payload, lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}
    con->pong(payload,ec);
}
Beispiel #2
0
void endpoint<connection,config>::send(connection_hdl hdl, message_ptr msg,
    lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}
    ec = con->send(msg);
}
Beispiel #3
0
void endpoint<connection,config>::send(connection_hdl hdl, void const * payload,
    size_t len, frame::opcode::value op, lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}
    ec = con->send(payload,len,op);
}
Beispiel #4
0
void endpoint<connection,config>::send_http_response(connection_hdl hdl,
    lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}
    con->send_http_response(ec);
}
Beispiel #5
0
void endpoint<connection,config>::resume_reading(connection_hdl hdl, lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}

    ec = con->resume_reading();
}
Beispiel #6
0
void endpoint<connection,config>::send(connection_hdl hdl, std::string const &
    payload, frame::opcode::value op, lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}

    ec = con->send(payload,op);
}
Beispiel #7
0
void endpoint<connection,config>::close(connection_hdl hdl, close::status::value
    const code, std::string const & reason,
    lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}
    con->close(code,reason,ec);
}
Beispiel #8
0
void endpoint<connection,config>::interrupt(connection_hdl hdl, lib::error_code & ec)
{
    connection_ptr con = get_con_from_hdl(hdl,ec);
    if (ec) {return;}

    m_alog.write(log::alevel::devel,"Interrupting connection");

    ec = con->interrupt();
}
Beispiel #9
0
EndpointPtr04  WebSocket04::makeEndpoint (HandlerPtr&& handler)
{
    auto endpoint = std::make_shared <Endpoint> (std::move (handler));

    endpoint->set_open_handler (
        [endpoint] (websocketpp::connection_hdl hdl) {
            if (auto conn = endpoint->get_con_from_hdl(hdl))
                endpoint->handler()->on_open (conn);
        });

    endpoint->set_close_handler (
        [endpoint] (websocketpp::connection_hdl hdl) {
            if (auto conn = endpoint->get_con_from_hdl(hdl))
                endpoint->handler()->on_close (conn);
        });

    endpoint->set_fail_handler (
        [endpoint] (websocketpp::connection_hdl hdl) {
            if (auto conn = endpoint->get_con_from_hdl(hdl))
                endpoint->handler()->on_fail (conn);
        });

    endpoint->set_pong_handler (
        [endpoint] (websocketpp::connection_hdl hdl, std::string data) {
            if (auto conn = endpoint->get_con_from_hdl(hdl))
                endpoint->handler()->on_pong (conn, data);
        });

    endpoint->set_http_handler (
        [endpoint] (websocketpp::connection_hdl hdl) {
            if (auto conn = endpoint->get_con_from_hdl(hdl))
                endpoint->handler()->http (conn);
        });

    endpoint->set_message_handler (
        [endpoint] (websocketpp::connection_hdl hdl,
                    MessagePtr msg) {
            if (auto conn = endpoint->get_con_from_hdl(hdl))
                endpoint->handler()->on_message (conn, msg);
        });

    endpoint->set_send_empty_handler (
        [endpoint] (websocketpp::connection_hdl hdl) {
            if (auto conn = endpoint->get_con_from_hdl(hdl))
                endpoint->handler()->on_send_empty (conn);
        });

    endpoint->init_asio();

    return endpoint;
}