mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Small Websocket cleanups.
This commit is contained in:
committed by
Nik Bougalis
parent
5c5ee6f763
commit
dabc5567f7
@@ -38,7 +38,7 @@ class AutoSocket
|
||||
public:
|
||||
using ssl_socket = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>;
|
||||
using endpoint_type = boost::asio::ip::tcp::socket::endpoint_type;
|
||||
using socket_ptr = std::shared_ptr<ssl_socket>;
|
||||
using socket_ptr = std::unique_ptr<ssl_socket>;
|
||||
using plain_socket = ssl_socket::next_layer_type;
|
||||
using lowest_layer_type = ssl_socket::lowest_layer_type;
|
||||
using handshake_type = ssl_socket::handshake_type;
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
, mBuffer ((plainOnly || secureOnly) ? 0 : 4)
|
||||
, j_ (ripple::debugJournal())
|
||||
{
|
||||
mSocket = std::make_shared<ssl_socket> (s, c);
|
||||
mSocket = std::make_unique<ssl_socket> (s, c);
|
||||
}
|
||||
|
||||
AutoSocket (
|
||||
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = it->second;
|
||||
ptr = std::move (it->second);
|
||||
// prevent the ConnectionImpl from being destroyed until we release
|
||||
// the lock
|
||||
mMap.erase (it);
|
||||
@@ -298,7 +298,10 @@ public:
|
||||
app_.getJobQueue ().addJob (
|
||||
jtCLIENT,
|
||||
"WSClient::destroy",
|
||||
[ptr] (Job&) { ConnectionImpl <WebSocket>::destroy(ptr); });
|
||||
[p = std::move(ptr)] (Job&)
|
||||
{
|
||||
ConnectionImpl <WebSocket>::destroy(std::move (p));
|
||||
});
|
||||
}
|
||||
|
||||
void message_job(std::string const& name, connection_ptr const& cpClient)
|
||||
|
||||
@@ -133,18 +133,15 @@ public:
|
||||
callback(error);
|
||||
}
|
||||
|
||||
// note, this function for some reason shouldn't/doesn't need to be
|
||||
// called for plain HTTP connections. not sure why.
|
||||
// Only SSL conections actually need to be shut down
|
||||
bool shutdown() {
|
||||
boost::system::error_code ignored_ec;
|
||||
|
||||
m_socket_ptr->async_shutdown( // Don't block on connection shutdown DJS
|
||||
std::bind(
|
||||
&autotls<endpoint_type>::handle_shutdown,
|
||||
&autotls<endpoint_type>::handle_shutdown,
|
||||
m_socket_ptr,
|
||||
beast::asio::placeholders::error
|
||||
)
|
||||
);
|
||||
beast::asio::placeholders::error));
|
||||
|
||||
if (ignored_ec) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user