refactor: Twitch PubSub client (#5059)

* Remove unused `setAccountData` function

* Move PubSub out of TwitchIrcServer and into Application

* Add changelog entry

* fix: assert feedback

* Add PubSub::unlistenPrefix as per review suggestion

* Fix tests

* quit pubsub on exit

might conflict with exit removal, so can be reverted but this shows it's possible

* Don't manually call stop on clients, it's called when the connection is closed

* nit: rename `mainThread` to `thread`

* Join in a thread!!!!!!!!
This commit is contained in:
pajlada
2024-01-06 13:18:37 +01:00
committed by GitHub
parent e48d868e8c
commit 416806bb0a
14 changed files with 458 additions and 484 deletions
+1 -5
View File
@@ -1,4 +1,4 @@
#include "TwitchIrcServer.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "Application.hpp"
#include "common/Channel.hpp"
@@ -13,7 +13,6 @@
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
#include "providers/twitch/IrcMessageHandler.hpp"
#include "providers/twitch/PubSubManager.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "singletons/Settings.hpp"
@@ -29,7 +28,6 @@ using namespace std::chrono_literals;
namespace {
const QString TWITCH_PUBSUB_URL = "wss://pubsub-edge.twitch.tv";
const QString BTTV_LIVE_UPDATES_URL = "wss://sockets.betterttv.net/ws";
const QString SEVENTV_EVENTAPI_URL = "wss://events.7tv.io/v3";
@@ -43,7 +41,6 @@ TwitchIrcServer::TwitchIrcServer()
, liveChannel(new Channel("/live", Channel::Type::TwitchLive))
, automodChannel(new Channel("/automod", Channel::Type::TwitchAutomod))
, watchingChannel(Channel::getEmpty(), Channel::Type::TwitchWatching)
, pubsub(new PubSub(TWITCH_PUBSUB_URL))
{
this->initializeIrc();
@@ -72,7 +69,6 @@ void TwitchIrcServer::initialize(Settings &settings, Paths &paths)
getApp()->accounts->twitch.currentUserChanged.connect([this]() {
postToThread([this] {
this->connect();
this->pubsub->setAccount(getApp()->accounts->twitch.getCurrent());
});
});