mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 10:32:58 +01:00
resolve #1347 Support limited metadata for STREAM sockets
This commit is contained in:
@@ -192,14 +192,23 @@ void zmq::stream_engine_t::plug (io_thread_t *io_thread_,
|
||||
handshaking = false;
|
||||
|
||||
next_msg = &stream_engine_t::pull_msg_from_session;
|
||||
process_msg = &stream_engine_t::push_msg_to_session;
|
||||
process_msg = &stream_engine_t::push_raw_msg_to_session;
|
||||
|
||||
if (!peer_address.empty()) {
|
||||
// Compile metadata.
|
||||
typedef metadata_t::dict_t properties_t;
|
||||
properties_t properties;
|
||||
properties.insert(std::make_pair("Peer-Address", peer_address));
|
||||
zmq_assert (metadata == NULL);
|
||||
metadata = new (std::nothrow) metadata_t (properties);
|
||||
}
|
||||
|
||||
if (options.raw_notify) {
|
||||
// For raw sockets, send an initial 0-length message to the
|
||||
// application so that it knows a peer has connected.
|
||||
msg_t connector;
|
||||
connector.init();
|
||||
push_msg_to_session (&connector);
|
||||
push_raw_msg_to_session (&connector);
|
||||
connector.close();
|
||||
session->flush ();
|
||||
}
|
||||
@@ -835,6 +844,12 @@ int zmq::stream_engine_t::push_msg_to_session (msg_t *msg_)
|
||||
return session->push_msg (msg_);
|
||||
}
|
||||
|
||||
int zmq::stream_engine_t::push_raw_msg_to_session (msg_t *msg_) {
|
||||
if (metadata)
|
||||
msg_->set_metadata(metadata);
|
||||
return push_msg_to_session(msg_);
|
||||
}
|
||||
|
||||
int zmq::stream_engine_t::write_credential (msg_t *msg_)
|
||||
{
|
||||
zmq_assert (mechanism != NULL);
|
||||
|
||||
Reference in New Issue
Block a user