Start cleaning up some of the bastardization.

This commit is contained in:
JoelKatz
2013-01-24 21:04:42 -08:00
parent c04b76e1ca
commit 938357b7ae
2 changed files with 35 additions and 26 deletions

View File

@@ -103,6 +103,32 @@ public:
PlainSocket().async_read_some(buffers, handler);
}
template <typename Buf, typename Handler> void async_write(const Buf& buffers, Handler handler)
{
if (isSecure())
boost::asio::async_write(*mSocket, buffers, handler);
else
boost::asio::async_write(PlainSocket(), buffers, handler);
}
template <typename Buf, typename Condition, typename Handler>
void async_read(const Buf& buffers, Condition cond, Handler handler)
{
if (isSecure())
boost::asio::async_read(*mSocket, buffers, cond, handler);
else
boost::asio::async_read(PlainSocket(), buffers, cond, handler);
}
template <typename Buf, typename Handler> void async_read(const Buf& buffers, Handler handler)
{
if (isSecure())
boost::asio::async_read(*mSocket, buffers, handler);
else
boost::asio::async_read(PlainSocket(), buffers, handler);
}
template <typename Seq, typename Handler> void async_write_some(const Seq& buffers, Handler handler)
{
if (isSecure())

View File

@@ -845,32 +845,15 @@ void server<endpoint>::connection<connection_type>::write_response() {
m_endpoint.m_alog->at(log::alevel::DEBUG_HANDSHAKE) << raw << log::endl;
if (m_connection.get_socket().isSecure())
{
boost::asio::async_write(
m_connection.get_socket().SSLSocket(),
//boost::asio::buffer(raw),
buffer,
boost::bind(
&type::handle_write_response,
m_connection.shared_from_this(),
boost::asio::placeholders::error
)
);
}
else
{
boost::asio::async_write(
m_connection.get_socket().PlainSocket(),
//boost::asio::buffer(raw),
buffer,
boost::bind(
&type::handle_write_response,
m_connection.shared_from_this(),
boost::asio::placeholders::error
)
);
}
m_connection.get_socket().async_write(
//boost::asio::buffer(raw),
buffer,
boost::bind(
&type::handle_write_response,
m_connection.shared_from_this(),
boost::asio::placeholders::error
)
);
}
template <class endpoint>