Also emit subscription events from close handler
This commit is contained in:
@@ -258,6 +258,13 @@ private:
|
|||||||
/* Emit close event */
|
/* Emit close event */
|
||||||
auto *webSocketContextData = (WebSocketContextData<SSL, USERDATA> *) us_socket_context_ext(SSL, us_socket_context(SSL, (us_socket_t *) s));
|
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 */
|
/* Make sure to unsubscribe from any pub/sub node at exit */
|
||||||
webSocketContextData->topicTree->freeSubscriber(webSocketData->subscriber);
|
webSocketContextData->topicTree->freeSubscriber(webSocketData->subscriber);
|
||||||
webSocketData->subscriber = nullptr;
|
webSocketData->subscriber = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user