diff --git a/tests/message.cpp b/tests/message.cpp index 014ac3cc..6ff81e1a 100644 --- a/tests/message.cpp +++ b/tests/message.cpp @@ -126,4 +126,11 @@ TEST(message, routing_id_persists) msg.set_routing_id(123); ASSERT_EQ(123u, msg.routing_id()); } + +TEST(message, group_persists) +{ + zmq::message_t msg; + msg.set_group("mygroup"); + ASSERT_STREQ("mygroup", msg.group()); +} #endif diff --git a/zmq.hpp b/zmq.hpp index e0d56719..97bca4e1 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -409,6 +409,18 @@ class message_t if (rc != 0) throw error_t(); } + + inline const char* group() const + { + return zmq_msg_group(const_cast(&msg)); + } + + inline void set_group(const char* group) + { + int rc = zmq_msg_set_group(&msg, group); + if (rc != 0) + throw error_t(); + } #endif /** Dump content to string. Ascii chars are readable, the rest is printed as hex. @@ -546,9 +558,11 @@ enum class socket_type : int xsub = ZMQ_XSUB, push = ZMQ_PUSH, pull = ZMQ_PULL, -#ifdef ZMQ_BUILD_DRAFT_API +#if defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 0) server = ZMQ_SERVER, client = ZMQ_CLIENT, + radio = ZMQ_RADIO, + dish = ZMQ_DISH, #endif #if ZMQ_VERSION_MAJOR >= 4 stream = ZMQ_STREAM, @@ -715,6 +729,22 @@ class socket_t throw error_t(); } +#if defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 0) + inline void join(const char* group) + { + int rc = zmq_join(ptr, group); + if (rc != 0) + throw error_t(); + } + + inline void leave(const char* group) + { + int rc = zmq_leave(ptr, group); + if (rc != 0) + throw error_t(); + } +#endif + private: inline void init(context_t &context_, int type_) {