Add WebSocket::unsubscribeAll

This commit is contained in:
Alex Hultman
2020-01-12 17:46:29 +01:00
parent 108d4f527f
commit 02f1ceeba0
+11
View File
@@ -198,6 +198,17 @@ public:
return webSocketContextData->topicTree.unsubscribe(topic, webSocketData->subscriber);
}
/* Unsubscribe from all topics you might be subscribed to */
void unsubscribeAll() {
WebSocketContextData<SSL> *webSocketContextData = (WebSocketContextData<SSL> *) us_socket_context_ext(SSL,
(us_socket_context_t *) us_socket_context(SSL, (us_socket_t *) this)
);
WebSocketData *webSocketData = (WebSocketData *) us_socket_ext(SSL, (us_socket_t *) this);
webSocketContextData->topicTree.unsubscribeAll(webSocketData->subscriber);
}
/* Publish a message to a topic according to MQTT rules and syntax */
void publish(std::string_view topic, std::string_view message, OpCode opCode = OpCode::TEXT, bool compress = false) {
WebSocketContextData<SSL> *webSocketContextData = (WebSocketContextData<SSL> *) us_socket_context_ext(SSL,