Skip to content
Snippets Groups Projects
Commit ac8b5394 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Add publish tests and pubsub appears to work

parent 32795d0c
No related branches found
No related tags found
No related merge requests found
......@@ -204,7 +204,7 @@ void Universe::publish(const std::string &res, ARGS... args) {
for (auto p : subs) {
auto peer = getPeer(p);
if (peer) {
*peer->send(res, args...);
peer->send(res, args...);
}
}
}
......
......@@ -192,6 +192,33 @@ TEST_CASE("Universe::subscribe()", "") {
}
}
TEST_CASE("Universe::publish()", "") {
Universe a;
Universe b;
a.listen("tcp://localhost:7077");
b.connect("tcp://localhost:7077");
while (a.numberOfPeers() == 0) sleep_for(milliseconds(20));
SECTION("no subscribers") {
a.createResource("ftl://test");
a.publish("ftl://test", 55);
}
SECTION("one subscriber") {
int done = 0;
a.createResource("ftl://test");
REQUIRE( b.subscribe("ftl://test", [&done](int a) {
done = a;
}) );
sleep_for(milliseconds(50));
a.publish("ftl://test", 56);
sleep_for(milliseconds(50));
REQUIRE( done == 56 );
}
}
/*TEST_CASE("net::listen()", "[net]") {
SECTION("tcp any interface") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment