More fixes for bind and shared_ptrs.

This commit is contained in:
Arthur Britto
2012-07-01 23:29:36 -07:00
parent 4c8810d5f6
commit f794254979
2 changed files with 12 additions and 8 deletions

View File

@@ -100,7 +100,7 @@ void RPCServer::connected()
else mRole=GUEST;
mSocket.async_read_some(boost::asio::buffer(mReadBuffer),
boost::bind(&RPCServer::handle_read, shared_from_this(),
boost::bind(&RPCServer::Shandle_read, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
@@ -127,7 +127,7 @@ void RPCServer::handle_read(const boost::system::error_code& e,
else
{ // not done keep reading
mSocket.async_read_some(boost::asio::buffer(mReadBuffer),
boost::bind(&RPCServer::handle_read, shared_from_this(),
boost::bind(&RPCServer::Shandle_read, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
@@ -2070,7 +2070,7 @@ void RPCServer::sendReply()
{
//std::cout << "RPC reply: " << mReplyStr << std::endl;
boost::asio::async_write(mSocket, boost::asio::buffer(mReplyStr),
boost::bind(&RPCServer::handle_write, shared_from_this(),
boost::bind(&RPCServer::Shandle_write, shared_from_this(),
boost::asio::placeholders::error));
}
@@ -2099,7 +2099,7 @@ void RPCServer::handle_write(const boost::system::error_code& e)
mIncomingRequest.headers.clear();
mRequestParser.reset();
mSocket.async_read_some(boost::asio::buffer(mReadBuffer),
boost::bind(&RPCServer::handle_read, shared_from_this(),
boost::bind(&RPCServer::Shandle_read, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}

View File

@@ -71,6 +71,8 @@ public:
Json::Value RPCError(int iError);
typedef boost::shared_ptr<RPCServer> pointer;
private:
typedef Json::Value (RPCServer::*doFuncPtr)(const Json::Value &params);
enum {
@@ -96,9 +98,13 @@ private:
RPCServer(const RPCServer&); // no implementation
RPCServer& operator=(const RPCServer&); // no implementation
void handle_write(const boost::system::error_code& error);
void handle_write(const boost::system::error_code& ec);
static void Shandle_write(pointer This, const boost::system::error_code& ec)
{ This->handle_write(ec); }
void handle_read(const boost::system::error_code& e, std::size_t bytes_transferred);
void handle_read(const boost::system::error_code& ec, std::size_t bytes_transferred);
static void Shandle_read(pointer This, const boost::system::error_code& ec, std::size_t bytes_transferred)
{ This->handle_read(ec, bytes_transferred); }
std::string handleRequest(const std::string& requestStr);
void sendReply();
@@ -166,8 +172,6 @@ private:
Json::Value doLogin(const Json::Value& params);
public:
typedef boost::shared_ptr<RPCServer> pointer;
static pointer create(boost::asio::io_service& io_service, NetworkOPs* mNetOps)
{
return pointer(new RPCServer(io_service, mNetOps));