diff options
| author | Per Larsson <[email protected]> | 2022-02-22 09:21:33 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-02-22 09:21:33 +0100 |
| commit | 8754206c4a2da9cd1912d47f33e29d26392b75cd (patch) | |
| tree | 79e413eb193ae35dcd5b647f434dcd908abf10a9 /zenhttp/websocketasio.cpp | |
| parent | Removed using enum statements. (diff) | |
| download | zen-8754206c4a2da9cd1912d47f33e29d26392b75cd.tar.xz zen-8754206c4a2da9cd1912d47f33e29d26392b75cd.zip | |
Fixed crashing websocket test.
Diffstat (limited to 'zenhttp/websocketasio.cpp')
| -rw-r--r-- | zenhttp/websocketasio.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/zenhttp/websocketasio.cpp b/zenhttp/websocketasio.cpp index e9d065624..12b762b12 100644 --- a/zenhttp/websocketasio.cpp +++ b/zenhttp/websocketasio.cpp @@ -754,11 +754,7 @@ WsServer::CloseConnection(std::shared_ptr<WsConnection> Connection, const std::e { if (Ec) { - ZEN_LOG_INFO(LogWebSocket, - "connection '{}' closed, ERROR '{}' error code '{}'", - Connection->Id().Value(), - Ec.message(), - Ec.value()); + ZEN_LOG_INFO(LogWebSocket, "connection '{}' closed, reason '{} ({})'", Connection->Id().Value(), Ec.message(), Ec.value()); } else { @@ -1304,6 +1300,13 @@ WsClient::ReadMessage() m_ReadBuffer, asio::transfer_at_least(1), [Self = AsShared()](const asio::error_code& Ec, std::size_t ByteCount) mutable { + const WebSocketState State = Self->State(); + + if (State == WebSocketState::kDisconnected) + { + return; + } + if (Ec) { ZEN_LOG_WARN(LogWsClient, "read message FAILED, reason '{}'", Ec.message()); @@ -1311,8 +1314,6 @@ WsClient::ReadMessage() return Self->Disconnect(); } - const WebSocketState State = Self->State(); - switch (State) { case WebSocketState::kHandshaking: |