void handle_error(ranger::event::tcp_connection& conn)
	{
		auto ep = conn.remote_endpoint();
		std::cerr << "connection[" << ep << "] " << "error[" << conn.error_code() << "]: " << conn.error_description() << std::endl;

		m_conn_set.erase(conn);
	}
	void handle_eof(ranger::event::tcp_connection& conn)
	{
		auto ep = conn.remote_endpoint();
		std::cerr << "connection[" << ep << "] " << "eof." << std::endl;

		m_conn_set.erase(conn);
	}
	void handle_read(ranger::event::tcp_connection& conn, ranger::event::buffer&& buf)
	{
		std::vector<char> v(buf.size());
		buf.remove(&v.front(), v.size());
		for (auto ch: v) std::cout << ch << std::flush;
		conn.write_buffer().append(&v.front(), v.size());
	}
	void handle_timeout(ranger::event::tcp_connection& conn)
	{
		auto ep = conn.remote_endpoint();
		std::cerr << "thread[" << std::this_thread::get_id() << "] " << "connection[" << ep << "] " << "timeout." << std::endl;

		m_conn_set.erase(conn);
	}
	void handle_read(ranger::event::tcp_connection& conn, ranger::event::buffer&& buf)
	{
		std::cout << "thread[" << std::this_thread::get_id() << "] " << __FUNCTION__ << std::endl;
		conn.write_buffer().append(buf);
	}
Esempio n. 6
0
	void handle_read(ranger::event::tcp_connection& conn, ranger::event::buffer&& buf) {
		conn.write_buffer().append(buf);
	}