@@ -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<rapidjson::Document>(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)
|
||||
|
||||
Reference in New Issue
Block a user