Also emit subscription events from close handler

This commit is contained in:
uNetworkingAB
2023-01-08 23:38:08 +01:00
committed by GitHub
parent 4821d090fe
commit 286b2f2f1f
+7
View File
@@ -258,6 +258,13 @@ private:
/* Emit close event */
auto *webSocketContextData = (WebSocketContextData<SSL, USERDATA> *) us_socket_context_ext(SSL, us_socket_context(SSL, (us_socket_t *) s));
/* At this point we iterate all currently held subscriptions and emit an event for all of them */
if (webSocketData->subscriber && webSocketContextData->subscriptionHandler) {
for (Topic *t : webSocketData->subscriber->topics) {
webSocketContextData->subscriptionHandler(this, t->name, (int) t->size() - 1, (int) t->size());
}
}
/* Make sure to unsubscribe from any pub/sub node at exit */
webSocketContextData->topicTree->freeSubscriber(webSocketData->subscriber);
webSocketData->subscriber = nullptr;