mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-05-03 15:58:27 +02:00
Add support for RADIO/DISH sockets if draft API is enabled
This commit introduces new socket_type enumeration values as well as the following supporting functions: socket_t::join() socket_t::leave() message_t::group() message_t::set_group()
This commit is contained in:
parent
73f171abb2
commit
751f27d635
@ -126,4 +126,11 @@ TEST(message, routing_id_persists)
|
|||||||
msg.set_routing_id(123);
|
msg.set_routing_id(123);
|
||||||
ASSERT_EQ(123u, msg.routing_id());
|
ASSERT_EQ(123u, msg.routing_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(message, group_persists)
|
||||||
|
{
|
||||||
|
zmq::message_t msg;
|
||||||
|
msg.set_group("mygroup");
|
||||||
|
ASSERT_STREQ("mygroup", msg.group());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
32
zmq.hpp
32
zmq.hpp
@ -409,6 +409,18 @@ class message_t
|
|||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
throw error_t();
|
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
|
#endif
|
||||||
|
|
||||||
/** Dump content to string. Ascii chars are readable, the rest is printed as hex.
|
/** 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,
|
xsub = ZMQ_XSUB,
|
||||||
push = ZMQ_PUSH,
|
push = ZMQ_PUSH,
|
||||||
pull = ZMQ_PULL,
|
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,
|
server = ZMQ_SERVER,
|
||||||
client = ZMQ_CLIENT,
|
client = ZMQ_CLIENT,
|
||||||
|
radio = ZMQ_RADIO,
|
||||||
|
dish = ZMQ_DISH,
|
||||||
#endif
|
#endif
|
||||||
#if ZMQ_VERSION_MAJOR >= 4
|
#if ZMQ_VERSION_MAJOR >= 4
|
||||||
stream = ZMQ_STREAM,
|
stream = ZMQ_STREAM,
|
||||||
@ -715,6 +729,22 @@ class socket_t
|
|||||||
throw error_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:
|
private:
|
||||||
inline void init(context_t &context_, int type_)
|
inline void init(context_t &context_, int type_)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user