$treeview $search $mathjax
00001 #ifndef __AIRINV_SVR_CONNECTION_HPP 00002 #define __AIRINV_SVR_CONNECTION_HPP 00003 00004 // ////////////////////////////////////////////////////////////////////// 00005 // Import section 00006 // ////////////////////////////////////////////////////////////////////// 00007 // STL 00008 // Boost 00009 #include <boost/asio.hpp> 00010 #include <boost/array.hpp> 00011 #include <boost/noncopyable.hpp> 00012 #include <boost/shared_ptr.hpp> 00013 #include <boost/enable_shared_from_this.hpp> 00014 // AirInv 00015 #include <airinv/server/Reply.hpp> 00016 #include <airinv/server/Request.hpp> 00017 00018 namespace AIRINV { 00019 00020 // Forward declarations. 00021 class RequestHandler; 00022 00023 00025 class Connection : public boost::enable_shared_from_this<Connection>, 00026 private boost::noncopyable { 00027 public: 00028 // //////////// Constructors and Destructors ///////////////// 00031 Connection (boost::asio::io_service&, RequestHandler&); 00032 00033 00034 // /////////// Business Support Methods //////////////// 00036 boost::asio::ip::tcp::socket& socket(); 00037 00039 void start(); 00040 00041 00042 private: 00044 void handleRead (const boost::system::error_code& e, 00045 std::size_t bytes_transferred); 00046 00048 void handleWrite (const boost::system::error_code& e); 00049 00052 boost::asio::io_service::strand _strand; 00053 00055 boost::asio::ip::tcp::socket _socket; 00056 00058 RequestHandler& _requestHandler; 00059 00061 boost::array<char, 8192> _buffer; 00062 00064 Request _request; 00065 00067 Reply _reply; 00068 }; 00069 00071 typedef boost::shared_ptr<Connection> ConnectionShrPtr_T; 00072 00073 } 00074 #endif // __AIRINV_SVR_CONNECTION_HPP