00001 #ifndef _BOOST_RPC_JSON_TCP_CONNECTION_HPP_
00002 #define _BOOST_RPC_JSON_TCP_CONNECTION_HPP_
00003 #include <boost/rpc/json.hpp>
00004 #include <boost/cmt/thread.hpp>
00005 #include <boost/rpc/json/connection.hpp>
00006 #include <boost/cmt/asio/tcp/socket.hpp>
00007 #include <boost/cmt/asio.hpp>
00008
00009 namespace boost { namespace rpc { namespace json { namespace tcp {
00013 class connection : public boost::rpc::json::connection {
00014 public:
00015 typedef boost::cmt::retainable_ptr<connection> ptr;
00016 typedef boost::cmt::asio::tcp::socket::ptr sock_ptr;
00017
00018 connection( const sock_ptr& s );
00019 connection(){}
00020
00021 bool connect( const std::string& hostname, const std::string& port );
00022 bool is_connected()const;
00023
00024 void send( const boost::json::Value& v );
00025 void start();
00026
00027 private:
00028 void read_loop();
00029 boost::function<void(const boost::json::Value& v)> m_recv_handler;
00030 sock_ptr m_sock;
00031 bool m_connected;
00032 };
00033
00034 } } } }
00035
00036 #endif