Hook up new pubsub

This commit is contained in:
Alex Hultman
2019-10-07 10:57:04 +02:00
parent a35d7f2ff3
commit d09f25850b
6 changed files with 39 additions and 8 deletions
+18 -1
View File
@@ -22,7 +22,7 @@
#include <string_view>
#include "WebSocketProtocol.h"
#include "TopicTree.h"
#include "TopicTreeDraft.h"
namespace uWS {
@@ -43,6 +43,23 @@ struct WebSocketContextData {
/* Each websocket context has a topic tree for pub/sub */
TopicTree topicTree;
WebSocketContextData() : topicTree([](Subscriber *s, std::string_view data) -> int {
//std::cout << "Skickar data: " << data << " på sub: " << s << std::endl;
auto *asyncSocket = (AsyncSocket<SSL> *) s;
asyncSocket->write(data.data(), data.length());
return 0;
}) {
Loop::get()->addPostHandler([this](Loop *loop) {
topicTree.drain();
});
}
};
}