Skip to content

Commit

Permalink
Merge pull request #256 from Tulon/radio_dish_support
Browse files Browse the repository at this point in the history
Add support for RADIO/DISH sockets if draft API is enabled
  • Loading branch information
bluca committed Jul 15, 2018
2 parents 73f171a + 751f27d commit 213da0b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 31 additions & 1 deletion zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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_)
{
Expand Down

0 comments on commit 213da0b

Please sign in to comment.