From 0f841f16afb9ffdb24eefb2e9f661d0139f0bf49 Mon Sep 17 00:00:00 2001 From: VitaliiTihobrazov-Melsoft <79570136+VitaliiTihobrazov-Melsoft@users.noreply.github.com> Date: Mon, 12 Apr 2021 23:45:09 +0300 Subject: [PATCH] fix: the connection must be closed in other states (#41) --- websocket/src/websocket.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket/src/websocket.cpp b/websocket/src/websocket.cpp index 4d552dc..0000985 100644 --- a/websocket/src/websocket.cpp +++ b/websocket/src/websocket.cpp @@ -251,10 +251,7 @@ static void CloseConnection(WebsocketConnection* conn) // we want it to send this message in the polling if (conn->m_State == STATE_CONNECTED) { #if defined(HAVE_WSLAY) - // close the connection and immediately transition to the DISCONNECTED - // state WSL_Close(conn->m_Ctx); - SetState(conn, STATE_DISCONNECTED); #else // start disconnecting by closing the WebSocket through the JS API // we transition to the DISCONNECTED state when we receive the @@ -264,6 +261,11 @@ static void CloseConnection(WebsocketConnection* conn) #endif } +#if defined(HAVE_WSLAY) + // close the connection and immediately transition to the DISCONNECTED + // state + SetState(conn, STATE_DISCONNECTED); +#endif } static bool IsConnectionValid(WebsocketConnection* conn)