diff --git a/impl/wsWslay/NWebsocketWslay.cpp b/impl/wsWslay/NWebsocketWslay.cpp index b94b89dd..609e3839 100644 --- a/impl/wsWslay/NWebsocketWslay.cpp +++ b/impl/wsWslay/NWebsocketWslay.cpp @@ -229,21 +229,21 @@ namespace Nakama { } this->_io->close(); + + _connected = false; + _state = State::Disconnected; + + // after close frame was sent or received wslay_context is tainted and need to be recreated + _ctx.reset(nullptr); + if (code) { - assert(_connected); NRtClientDisconnectInfo info; info.code = code.value(); info.remote = remote; fireOnDisconnected(info); } - _connected = false; - _state = State::Disconnected; - - // after close frame was sent or received wslay_context is tainted and need to be recreated - _ctx.reset(nullptr); } - uint32_t NWebsocketWslay::getActivityTimeout() const { return this->_timeout; }