diff --git a/plugins/twitch/event-sub.cpp b/plugins/twitch/event-sub.cpp index 9bd308b3..a4a37f8c 100644 --- a/plugins/twitch/event-sub.cpp +++ b/plugins/twitch/event-sub.cpp @@ -83,6 +83,10 @@ void EventSub::ConnectThread() } else { _client->connect(con); _connection = connection_hdl(con); + if (_disconnect) { + _client->close(con, websocketpp::close::status::normal, + "Twitch EventSub stopping", ec); + } _client->run(); } @@ -157,12 +161,6 @@ void EventSub::Disconnect() _cv.notify_all(); } - while (_connected) { - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - _client->close(_connection, websocketpp::close::status::normal, - "Twitch EventSub stopping", ec); - } - if (_thread.joinable()) { _thread.join(); } diff --git a/plugins/twitch/token.cpp b/plugins/twitch/token.cpp index aac39a9c..f62a4004 100644 --- a/plugins/twitch/token.cpp +++ b/plugins/twitch/token.cpp @@ -87,6 +87,7 @@ static bool setupTwitchTokenSupport() { AddSaveStep(saveConnections); AddLoadStep(loadConnections); + AddPluginCleanupStep([]() { twitchTokens.clear(); }); return true; }