mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
removes all old style handler code
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
//typedef websocketpp::server<concurrency,transport> server;
|
||||
typedef websocketpp::server<websocketpp::config::core> server;
|
||||
|
||||
class handler : public server::handler {
|
||||
/*class handler : public server::handler {
|
||||
bool validate(connection_ptr con) {
|
||||
std::cout << "handler validate" << std::endl;
|
||||
if (con->get_origin() != "http://www.example.com") {
|
||||
@@ -60,7 +60,7 @@ class handler : public server::handler {
|
||||
void on_close(connection_ptr con) {
|
||||
std::cout << "handler on_close" << std::endl;
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
||||
int main() {
|
||||
typedef websocketpp::message_buffer::message<websocketpp::message_buffer::alloc::con_msg_manager>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
typedef websocketpp::server<websocketpp::config::asio> server;
|
||||
|
||||
class handler : public server::handler {
|
||||
/*class handler : public server::handler {
|
||||
bool validate(connection_ptr con) {
|
||||
std::cout << "handler validate" << std::endl;
|
||||
return true;
|
||||
@@ -62,7 +62,7 @@ class handler : public server::handler {
|
||||
void on_interrupt(connection_ptr con) {
|
||||
std::cout << "handler on_interrupt" << std::endl;
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
||||
class test_handler {
|
||||
public:
|
||||
@@ -105,9 +105,7 @@ void on_message(server* s,websocketpp::connection_hdl hdl,message_ptr msg) {
|
||||
}
|
||||
|
||||
int main() {
|
||||
server::handler::ptr h(new handler());
|
||||
|
||||
server echo_server(h);
|
||||
server echo_server;
|
||||
|
||||
echo_server.init_asio();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
typedef websocketpp::server<websocketpp::config::asio_tls> server;
|
||||
|
||||
class handler : public server::handler {
|
||||
/*class handler : public server::handler {
|
||||
|
||||
std::string get_password() const {
|
||||
return "test";
|
||||
@@ -62,12 +62,10 @@ class handler : public server::handler {
|
||||
void on_close(connection_ptr con) {
|
||||
std::cout << "handler on_close" << std::endl;
|
||||
}
|
||||
};
|
||||
};*/
|
||||
|
||||
int main() {
|
||||
server::handler::ptr h(new handler());
|
||||
|
||||
server echo_server(h);
|
||||
server echo_server;
|
||||
|
||||
echo_server.init_asio();
|
||||
|
||||
|
||||
@@ -133,39 +133,6 @@ public:
|
||||
|
||||
typedef lib::function<void(ptr)> termination_handler;
|
||||
|
||||
class handler {
|
||||
public:
|
||||
typedef handler type;
|
||||
typedef lib::shared_ptr<type> ptr;
|
||||
typedef lib::weak_ptr<type> weak_ptr;
|
||||
|
||||
typedef typename connection::ptr connection_ptr;
|
||||
typedef typename config::message_type::ptr message_ptr;
|
||||
|
||||
//virtual void http(connection_ptr con) {}
|
||||
|
||||
// TODO: validate is server only. hide from client handlers?
|
||||
//virtual bool validate(connection_ptr con) {return true;}
|
||||
|
||||
//virtual void on_inturrupt(connection_ptr con) {}
|
||||
|
||||
//virtual void on_open(connection_ptr con) {}
|
||||
//virtual void on_fail(connection_ptr con) {}
|
||||
virtual void on_message(connection_ptr con, message_ptr msg) {}
|
||||
//virtual void on_close(connection_ptr con) {}
|
||||
|
||||
//virtual bool on_ping(connection_ptr con, const std::string &) {
|
||||
// return true;
|
||||
//}
|
||||
//virtual void on_pong(connection_ptr con, const std::string &) {}
|
||||
//virtual void on_pong_timeout(connection_ptr con, const std::string &) {}
|
||||
|
||||
virtual void on_load(connection_ptr con, ptr old_handler) {}
|
||||
virtual void on_unload(connection_ptr con, ptr new_handler) {}
|
||||
};
|
||||
|
||||
typedef typename handler::ptr handler_ptr;
|
||||
|
||||
typedef typename concurrency_type::scoped_lock_type scoped_lock_type;
|
||||
typedef typename concurrency_type::mutex_type mutex_type;
|
||||
|
||||
@@ -352,23 +319,6 @@ public:
|
||||
void set_message_handler(message_handler h) {
|
||||
m_message_handler = h;
|
||||
}
|
||||
|
||||
/// Set new connection handler
|
||||
/**
|
||||
* Will invoke the old handler's on_unload callback followed by the
|
||||
* new handler's on_load callback. These callbacks will both happen
|
||||
* immediately and before set_handler returns. If called in a method
|
||||
* within the connection's strand (such as another callback) the
|
||||
* next callback run after the present one will use the new state
|
||||
* including ones that are on the asio stack already but not yet
|
||||
* scheduled.
|
||||
*
|
||||
* This method may be called at any time.
|
||||
*
|
||||
* @param new_handler The new handler to switch to.
|
||||
*/
|
||||
void set_handler(handler_ptr new_handler);
|
||||
|
||||
|
||||
/// Return the same origin policy origin value from the opening request.
|
||||
/**
|
||||
@@ -847,9 +797,6 @@ private:
|
||||
validate_handler m_validate_handler;
|
||||
message_handler m_message_handler;
|
||||
|
||||
/// Legacy Handler
|
||||
handler_ptr m_handler;
|
||||
|
||||
/// External connection state
|
||||
/**
|
||||
* Lock: m_connection_state_lock
|
||||
|
||||
@@ -69,15 +69,12 @@ public:
|
||||
typedef typename connection_type::message_handler message_handler;
|
||||
|
||||
// TODO: organize these
|
||||
typedef typename connection_type::handler handler_type;
|
||||
typedef typename handler_type::ptr handler_ptr;
|
||||
typedef typename connection_type::termination_handler termination_handler;
|
||||
|
||||
typedef lib::shared_ptr<connection_weak_ptr> hdl_type;
|
||||
|
||||
explicit endpoint(handler_ptr default_handler, bool is_server)
|
||||
: m_default_handler(default_handler)
|
||||
, m_user_agent(::websocketpp::user_agent)
|
||||
explicit endpoint(bool is_server)
|
||||
: m_user_agent(::websocketpp::user_agent)
|
||||
, m_is_server(is_server)
|
||||
{
|
||||
std::cout << "endpoint constructor" << std::endl;
|
||||
@@ -177,7 +174,6 @@ protected:
|
||||
mutex_type m_mutex;
|
||||
private:
|
||||
// dynamic settings
|
||||
handler_ptr m_default_handler;
|
||||
std::string m_user_agent;
|
||||
|
||||
open_handler m_open_handler;
|
||||
|
||||
@@ -41,27 +41,6 @@ namespace websocketpp {
|
||||
|
||||
namespace istate = session::internal_state;
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::set_handler(handler_ptr new_handler) {
|
||||
std::cout << "connection set_handler" << std::endl;
|
||||
//scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (!new_handler) {
|
||||
// TODO
|
||||
throw std::logic_error("set_handler");
|
||||
}
|
||||
|
||||
handler_ptr old_handler = m_handler;
|
||||
if (old_handler) {
|
||||
old_handler->on_unload(type::shared_from_this(),new_handler);
|
||||
}
|
||||
m_handler = new_handler;
|
||||
|
||||
new_handler->on_load(type::shared_from_this(),old_handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::set_termination_handler(
|
||||
termination_handler new_handler)
|
||||
@@ -468,8 +447,6 @@ void connection<config>::handle_transport_init(const lib::error_code& ec) {
|
||||
// server: read/process/write/go
|
||||
// client: process/write/read/process/go
|
||||
|
||||
//m_handler->on_open(type::shared_from_this());
|
||||
|
||||
//this->read();
|
||||
}
|
||||
|
||||
@@ -685,7 +662,6 @@ void connection<config>::handle_read_frame(const lib::error_code& ec,
|
||||
std::cout << "null message from m_processor" << std::endl;
|
||||
} else if (!is_control(msg->get_opcode())) {
|
||||
// data message, dispatch to user
|
||||
//m_handler->on_message(type::shared_from_this(), msg);
|
||||
if (m_message_handler) {
|
||||
m_message_handler(m_connection_hdl, msg);
|
||||
}
|
||||
@@ -845,6 +821,7 @@ bool connection<config>::process_handshake_request() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: does this function still need to be here?
|
||||
template <typename config>
|
||||
void connection<config>::handle_read(const lib::error_code& ec,
|
||||
size_t bytes_transferred)
|
||||
@@ -867,7 +844,7 @@ void connection<config>::handle_read(const lib::error_code& ec,
|
||||
return;
|
||||
}
|
||||
|
||||
m_handler->on_message(type::shared_from_this(),foo);
|
||||
//m_handler->on_message(type::shared_from_this(),foo);
|
||||
|
||||
this->read();
|
||||
}
|
||||
|
||||
@@ -55,8 +55,6 @@ endpoint<connection,config>::create_connection() {
|
||||
//
|
||||
con->set_handle(w);
|
||||
|
||||
con->set_handler(m_default_handler);
|
||||
|
||||
// Copy default handlers from the endpoint
|
||||
con->set_open_handler(m_open_handler);
|
||||
con->set_close_handler(m_close_handler);
|
||||
|
||||
@@ -50,11 +50,6 @@ public:
|
||||
/// Type of the endpoint transport component
|
||||
typedef typename config::transport_type transport_type;
|
||||
|
||||
// connection policies
|
||||
//typedef role::server role_con_policy;
|
||||
//typedef concurrency_type concurrency_con_policy;
|
||||
//typedef typename transport_type::con_policy transport_con_policy;
|
||||
|
||||
/// Type of the connections this server will create
|
||||
typedef connection<config> connection_type;
|
||||
/// Type of a shared pointer to the connections this server will create
|
||||
@@ -70,12 +65,8 @@ public:
|
||||
|
||||
|
||||
// TODO: clean up these types
|
||||
typedef typename endpoint_type::handler_type handler_type;
|
||||
typedef handler_type handler; // for backwards compatibility
|
||||
typedef typename endpoint_type::handler_ptr handler_ptr;
|
||||
|
||||
explicit server(typename endpoint_type::handler_ptr default_handler)
|
||||
: endpoint_type(default_handler,true)
|
||||
explicit server() : endpoint_type(true)
|
||||
{
|
||||
std::cout << "server constructor" << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user