clear session on shutdown

This commit is contained in:
Nathan Nichols
2021-05-26 13:32:31 -05:00
parent 58413a7473
commit 95d48bdb1a
3 changed files with 12 additions and 24 deletions

View File

@@ -131,23 +131,3 @@ SubscriptionManager::unsubProposedTransactions(std::shared_ptr<session>& session
{
streamSubscribers_[TransactionsProposed].erase(session);
}
void
SubscriptionManager::clearSession(std::shared_ptr<session> const& session)
{
for(auto& stream : streamSubscribers_)
stream.erase(session);
for(auto& [account, subscribers] : accountSubscribers_)
{
if (subscribers.find(session) != subscribers.end())
accountSubscribers_[account].erase(session);
}
for(auto& [account, subscribers] : accountProposedSubscribers_)
{
if (subscribers.find(session) != subscribers.end())
accountProposedSubscribers_[account].erase(session);
}
}

View File

@@ -93,9 +93,6 @@ public:
void
unsubProposedTransactions(std::shared_ptr<session>& session);
void
clearSession(std::shared_ptr<session> const& session);
};
#endif //SUBSCRIPTION_MANAGER_H

View File

@@ -220,6 +220,17 @@ public:
&session::on_write, shared_from_this()));
}
void
close(boost::beast::websocket::close_reason const& cr)
{
boost::beast::error_code ec;
ws_.close(cr, ec);
if (ec)
return fail(ec, "close");
}
private:
// Get on the correct executor
@@ -287,7 +298,7 @@ private:
return;
if (ec)
return fail(ec, "read");
fail(ec, "read");
std::string msg{
static_cast<char const*>(buffer_.data().data()), buffer_.size()};