cluster/websocket: Short-circuit clients without subscriptions

This commit is contained in:
Arne Welzel 2025-04-23 18:12:51 +02:00
parent 47206d6a8a
commit 23f0370e91
6 changed files with 82 additions and 0 deletions

View file

@ -394,6 +394,14 @@ void WebSocketEventDispatcher::HandleSubscriptions(WebSocketClientEntry& entry,
entry.wsc->SetSubscriptions(subscriptions);
// Short-circuit setting up subscriptions and directly reply with
// an ack if the client didn't request any topic subscriptions.
if ( subscriptions.empty() ) {
assert(entry.wsc->AllSubscriptionsActive());
HandleSubscriptionsActive(entry);
return;
}
auto cb = [this, id = entry.id, wsc = entry.wsc](const std::string& topic,
const Backend::SubscriptionCallbackInfo& info) {
if ( info.status == Backend::CallbackStatus::Error ) {