Move in TopicTree from uTT

This commit is contained in:
Alex Hultman
2019-02-08 23:23:25 +01:00
parent e59ae7fd72
commit aaf1f05dcd
3 changed files with 174 additions and 3 deletions
+19
View File
@@ -125,6 +125,25 @@ public:
webSocketContextData->closeHandler(this, code, message);
}
}
/* Subscribe to a topic according to MQTT rules and syntax */
void subscribe(std::string_view topic) {
WebSocketContextData<SSL> *webSocketContextData = (WebSocketContextData<SSL> *) us_new_socket_context_ext(SSL,
(us_new_socket_context_t *) us_new_socket_context(SSL, (us_new_socket_t *) this)
);
/* Fix this up */
webSocketContextData->topicTree.subscribe(topic, this, nullptr);
}
/* Publish a message to a topic according to MQTT rules and syntax */
void publish(std::string_view topic, std::string_view message) {
WebSocketContextData<SSL> *webSocketContextData = (WebSocketContextData<SSL> *) us_new_socket_context_ext(SSL,
(us_new_socket_context_t *) us_new_socket_context(SSL, (us_new_socket_t *) this)
);
webSocketContextData->topicTree.publish(topic, message.data(), message.length());
}
};
}