Skip to content

Commit

Permalink
Add WebSocket::unsubscribeAll
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Jan 12, 2020
1 parent 108d4f5 commit 02f1cee
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/WebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ struct WebSocket : AsyncSocket<SSL> {
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,
Expand Down

0 comments on commit 02f1cee

Please sign in to comment.