diff --git a/src/providers/twitch/PubsubClient.cpp b/src/providers/twitch/PubsubClient.cpp index 7753d584..0e9c415a 100644 --- a/src/providers/twitch/PubsubClient.cpp +++ b/src/providers/twitch/PubsubClient.cpp @@ -729,7 +729,7 @@ PubSub::PubSub() // Add an initial client this->addClient(); -} // namespace chatterino +} void PubSub::addClient() { @@ -818,6 +818,8 @@ void PubSub::listen(rapidjson::Document &&msg) return; } + this->addClient(); + log("Added to the back of the queue"); this->requests.emplace_back( std::make_unique(std::move(msg))); @@ -936,6 +938,19 @@ void PubSub::onConnectionOpen(WebsocketHandle hdl) this->clients.emplace(hdl, client); this->connected.invoke(); + + for (auto it = this->requests.begin(); it != this->requests.end();) + { + const auto &request = *it; + if (client->listen(*request)) + { + it = this->requests.erase(it); + } + else + { + ++it; + } + } } void PubSub::onConnectionClose(WebsocketHandle hdl)