summaryrefslogtreecommitdiffhomepage
path: root/websocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'websocket.cpp')
-rw-r--r--websocket.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/websocket.cpp b/websocket.cpp
index d361ec1..8d4d27c 100644
--- a/websocket.cpp
+++ b/websocket.cpp
@@ -67,15 +67,16 @@ public:
void fail(boost::beast::error_code ec, char const* what)
{
- if (ec == websocket::error::closed)
- return;
-
boost::beast::error_code ec2;
+
if (auto& ws_in{derived().ws_in()}; ws_in.is_open())
ws_in.close(beast::websocket::close_code::going_away, ec2);
if (auto& ws_app{ws_app_}; ws_app.is_open())
ws_app.close(beast::websocket::close_code::going_away, ec2);
+ if (ec == websocket::error::closed)
+ return;
+
std::cerr << what << ": " << ec.message() << "\n";
}
@@ -191,10 +192,6 @@ private:
{
boost::ignore_unused(bytes_transferred);
- // This indicates that the websocket_session was closed
- if (ec == websocket::error::closed)
- return;
-
if (ec) {
// not error::closed as above, but no other strategy known
return fail(ec, "read in");