コード例 #1
0
void socketio_server_handler::validate(connection_ptr con) {
    std::stringstream err;

    // We only know about the chat resource
    if (con->get_resource() != resource_name_) {
        err << "Request for unknown resource " << con->get_resource();
        throw(websocketpp::http::exception(err.str(),websocketpp::http::status_code::NOT_FOUND));
    }

}
コード例 #2
0
ファイル: chat.cpp プロジェクト: moorecoin/MooreCoinService
void chat_server_handler::validate(connection_ptr con) {
    std::stringstream err;
    
    // we only know about the chat resource
    if (con->get_resource() != "/chat") {
        err << "request for unknown resource " << con->get_resource();
        throw(websocketpp::http::exception(err.str(),websocketpp::http::status_code::not_found));
    }
    
    // require specific origin example
    if (con->get_origin() != "http://zaphoyd.com") {
        err << "request from unrecognized origin: " << con->get_origin();
        throw(websocketpp::http::exception(err.str(),websocketpp::http::status_code::forbidden));
    }
}
コード例 #3
0
 void on_open(connection_ptr connection) {
     if (connection->get_resource() == "/admin") {
         connection->set_handler(m_admin_handler);
     } else {
         connection->set_handler(m_broadcast_handler);
     }
 }
コード例 #4
0
 void on_message(connection_ptr con, message_ptr msg) {        
     if (con->get_resource() == "/getcasecount") {
         std::cout << "detected " << msg->get_payload() << " test cases." << std::endl;
         m_case_count = atoi(msg->get_payload().c_str());
     } else {
         con->send(msg->get_payload(),msg->get_opcode());
     }
 }
コード例 #5
0
void WebSocketManager::on_validate(connection_ptr con)
{
    LogInfo("Request for resource: " + con->get_resource());
    //cout << "origin: " << con->get_origin() << endl;

}