mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-29 20:59:47 +01:00
problem: ZMQ_HEARTBEAT is not useful without sending an hello message
When using ZMQ_HEARTBEAT one still needs to implement application-level heartbeat in order to know when to send a hello message. For example, with the majordomo protocol, the worker needs to send a READY message when connecting to a broker. If the connection to the broker drops, and the heartbeat recognizes it the worker won't know about it and won't send the READY msg. To solve that, the majordomo worker still has to implement heartbeat. With this new option, whenever the connection drops and reconnects the hello message will be sent, greatly simplify the majordomo protocol, as now READY and HEARTBEAT can be handled by zeromq.
This commit is contained in:
@@ -249,7 +249,9 @@ zmq::options_t::options_t () :
|
||||
zero_copy (true),
|
||||
router_notify (0),
|
||||
monitor_event_version (1),
|
||||
wss_trust_system (false)
|
||||
wss_trust_system (false),
|
||||
hello_msg (),
|
||||
can_send_hello_msg (false)
|
||||
{
|
||||
memset (curve_public_key, 0, CURVE_KEYSIZE);
|
||||
memset (curve_secret_key, 0, CURVE_KEYSIZE);
|
||||
@@ -813,6 +815,19 @@ int zmq::options_t::setsockopt (int option_,
|
||||
return do_setsockopt_int_as_bool_strict (optval_, optvallen_,
|
||||
&wss_trust_system);
|
||||
#endif
|
||||
|
||||
case ZMQ_HELLO_MSG:
|
||||
if (optvallen_ > 0) {
|
||||
unsigned char *bytes = (unsigned char *) optval_;
|
||||
hello_msg =
|
||||
std::vector<unsigned char> (bytes, bytes + optvallen_);
|
||||
} else {
|
||||
hello_msg = std::vector<unsigned char> ();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user