Respond with error to hello, fix disconnect

This commit is contained in:
badaix 2025-02-11 22:44:29 +01:00 committed by Johannes Pohl
parent 9ce96a5cfe
commit 81f849bea9
3 changed files with 49 additions and 14 deletions

View file

@ -66,19 +66,37 @@ void StreamSessionWebsocket::start()
void StreamSessionWebsocket::stop()
{
LOG(DEBUG, LOG_TAG) << "stop\n";
boost::beast::error_code ec;
if (is_ssl_)
{
#if 0 // this might not return
if (ssl_ws_->is_open())
ssl_ws_->close(beast::websocket::close_code::normal, ec);
#endif
if (ssl_ws_->next_layer().lowest_layer().is_open())
{
ssl_ws_->next_layer().lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
ssl_ws_->next_layer().lowest_layer().close(ec);
}
}
else
{
#if 0 // this might not return
if (tcp_ws_->is_open())
tcp_ws_->close(beast::websocket::close_code::normal, ec);
#endif
if (tcp_ws_->next_layer().is_open())
{
tcp_ws_->next_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
tcp_ws_->next_layer().close(ec);
}
}
if (ec)
LOG(ERROR, LOG_TAG) << "Error in socket close: " << ec.message() << "\n";
LOG(DEBUG, LOG_TAG) << "stopped\n";
}