Merge pull request #256 from Tulon/radio_dish_support

Add support for RADIO/DISH sockets if draft API is enabled
This commit is contained in:
Luca Boccassi 2018-07-15 12:06:19 +01:00 committed by GitHub
commit 213da0b04a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 1 deletions

View File

@ -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

32
zmq.hpp
View File

@ -409,6 +409,18 @@ class message_t
if (rc != 0)
throw error_t();
}
inline const char* group() const
{
return zmq_msg_group(const_cast<zmq_msg_t*>(&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_)
{