diff --git a/oxenmq/message.h b/oxenmq/message.h index 73b96d0..aa399ad 100644 --- a/oxenmq/message.h +++ b/oxenmq/message.h @@ -75,6 +75,15 @@ public: explicit DeferredSend(Message& m) : oxenmq{m.oxenmq}, conn{m.conn}, reply_tag{m.reply_tag} {} + template + void operator()(Args &&...args) const { + if (reply_tag.empty()) + back(std::forward(args)...); + else + reply(std::forward(args)...); + }; + + /// Equivalent to msg.send_back(...), but can be invoked later. template void back(std::string_view command, Args&&... args) const; diff --git a/tests/test_commands.cpp b/tests/test_commands.cpp index 9dea29a..93e70c4 100644 --- a/tests/test_commands.cpp +++ b/tests/test_commands.cpp @@ -472,7 +472,7 @@ TEST_CASE("deferred replies", "[commands][send][deferred]") { { auto lock = catch_lock(); UNSCOPED_INFO("sleeping"); } std::this_thread::sleep_for(50ms * TIME_DILATION); { auto lock = catch_lock(); UNSCOPED_INFO("sending"); } - send.reply(msg); + send(msg); }}; t.detach(); });