summaryrefslogtreecommitdiff
path: root/src/zmq_encoder.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-02-12 15:57:54 +0100
committerMartin Sustrik <sustrik@250bpm.com>2010-02-12 15:57:54 +0100
commit36a576370ccfed3c104850b5b95a6ed3870edbea (patch)
treedbe228c0a27b7f75cc47a5b46da09f965e3ec5d3 /src/zmq_encoder.cpp
parent7b4cf2a4d040057f6f378cac2cd125513a859c1b (diff)
Multi-hop REQ/REP, part I., tracerouting switched on on XREP socket
Diffstat (limited to 'src/zmq_encoder.cpp')
-rw-r--r--src/zmq_encoder.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/zmq_encoder.cpp b/src/zmq_encoder.cpp
index 89649ef..a60fe5e 100644
--- a/src/zmq_encoder.cpp
+++ b/src/zmq_encoder.cpp
@@ -21,10 +21,10 @@
#include "i_inout.hpp"
#include "wire.hpp"
-zmq::zmq_encoder_t::zmq_encoder_t (size_t bufsize_, bool trim_prefix_) :
+zmq::zmq_encoder_t::zmq_encoder_t (size_t bufsize_) :
encoder_t <zmq_encoder_t> (bufsize_),
source (NULL),
- trim_prefix (trim_prefix_)
+ trim (false)
{
zmq_msg_init (&in_progress);
@@ -42,10 +42,15 @@ void zmq::zmq_encoder_t::set_inout (i_inout *source_)
source = source_;
}
+void zmq::zmq_encoder_t::trim_prefix ()
+{
+ trim = true;
+}
+
bool zmq::zmq_encoder_t::size_ready ()
{
// Write message body into the buffer.
- if (!trim_prefix) {
+ if (!trim) {
next_step (zmq_msg_data (&in_progress), zmq_msg_size (&in_progress),
&zmq_encoder_t::message_ready, false);
}
@@ -75,7 +80,7 @@ bool zmq::zmq_encoder_t::message_ready ()
// Get the message size. If the prefix is not to be sent, adjust the
// size accordingly.
size_t size = zmq_msg_size (&in_progress);
- if (trim_prefix)
+ if (trim)
size -= *(unsigned char*) zmq_msg_data (&in_progress);
// For messages less than 255 bytes long, write one byte of message size.