Fix potential event sub freeze on disconnect

This commit is contained in:
WarmUpTill 2026-04-29 14:18:05 +02:00
parent ab2762ebd3
commit a5ecb7975e
2 changed files with 5 additions and 6 deletions

View File

@ -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();
}

View File

@ -87,6 +87,7 @@ static bool setupTwitchTokenSupport()
{
AddSaveStep(saveConnections);
AddLoadStep(loadConnections);
AddPluginCleanupStep([]() { twitchTokens.clear(); });
return true;
}