mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-28 09:30:21 +00:00
close websocket on destructor
This commit is contained in:
@@ -107,6 +107,7 @@ boost::json::object
|
||||
doLedger(
|
||||
boost::json::object const& request,
|
||||
BackendInterface const& backend);
|
||||
|
||||
boost::json::object
|
||||
doLedgerRange(
|
||||
boost::json::object const& request,
|
||||
@@ -204,7 +205,10 @@ public:
|
||||
)->run();
|
||||
}
|
||||
|
||||
~session() = default;
|
||||
~session()
|
||||
{
|
||||
close(1012);
|
||||
}
|
||||
|
||||
void
|
||||
send(std::string&& msg)
|
||||
@@ -216,6 +220,15 @@ public:
|
||||
&session::on_write, shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
close(boost::beast::websocket::close_reason const& cr)
|
||||
{
|
||||
ws_.async_close(
|
||||
cr,
|
||||
boost::beast::bind_front_handler(
|
||||
&session::on_close, shared_from_this()));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Get on the correct executor
|
||||
@@ -329,7 +342,7 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
on_write(boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||
on_write(boost::beast::error_code const& ec, std::size_t bytes_transferred)
|
||||
{
|
||||
boost::ignore_unused(bytes_transferred);
|
||||
|
||||
@@ -342,6 +355,13 @@ private:
|
||||
// Do another read
|
||||
do_read();
|
||||
}
|
||||
|
||||
void
|
||||
on_close(boost::beast::error_code const& ec)
|
||||
{
|
||||
if (ec)
|
||||
return fail(ec, "close");
|
||||
}
|
||||
};
|
||||
|
||||
#endif // RIPPLE_REPORTING_SESSION_H
|
||||
Reference in New Issue
Block a user