aboutsummaryrefslogtreecommitdiffstats
path: root/src/OutputZeroMQ.cpp
diff options
context:
space:
mode:
authorKenneth Mortensen <mortensenit@users.noreply.github.com>2015-04-22 11:39:19 +0200
committerKenneth Mortensen <mortensenit@users.noreply.github.com>2015-04-22 11:39:19 +0200
commitd45f9b924c54fc40c228b8d3709e93fed7720705 (patch)
tree1192e317e6fdfae692f67843400b698c49ee7a1f /src/OutputZeroMQ.cpp
parent191817b42ad86a250bbff02895e9646f51531672 (diff)
parent81775f47227c5d08a05b43ffb3855bff0a237c1d (diff)
downloaddabmod-d45f9b924c54fc40c228b8d3709e93fed7720705.tar.gz
dabmod-d45f9b924c54fc40c228b8d3709e93fed7720705.tar.bz2
dabmod-d45f9b924c54fc40c228b8d3709e93fed7720705.zip
Merge remote-tracking branch 'upstream/master'
Conflicts: src/InputFileReader.cpp
Diffstat (limited to 'src/OutputZeroMQ.cpp')
-rw-r--r--src/OutputZeroMQ.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/OutputZeroMQ.cpp b/src/OutputZeroMQ.cpp
index 0e759dd..da4473e 100644
--- a/src/OutputZeroMQ.cpp
+++ b/src/OutputZeroMQ.cpp
@@ -30,21 +30,33 @@
#include <string.h>
#include <sstream>
-#if defined(HAVE_OUTPUT_ZEROMQ)
+#if defined(HAVE_ZEROMQ)
-OutputZeroMQ::OutputZeroMQ(std::string endpoint, Buffer* dataOut)
+OutputZeroMQ::OutputZeroMQ(std::string endpoint, int type, Buffer* dataOut)
: ModOutput(ModFormat(1), ModFormat(0)),
+ m_type(type),
m_zmq_context(1),
- m_zmq_pub_sock(m_zmq_context, ZMQ_PUB),
+ m_zmq_sock(m_zmq_context, type),
m_endpoint(endpoint)
{
PDEBUG("OutputZeroMQ::OutputZeroMQ(%p) @ %p\n", dataOut, this);
std::stringstream ss;
- ss << "OutputZeroMQ(" << m_endpoint << ")";
+ ss << "OutputZeroMQ(" << m_endpoint << " ";
+
+ if (type == ZMQ_PUB) {
+ ss << "ZMQ_PUB";
+ }
+ else if (type == ZMQ_REP) {
+ ss << "ZMQ_REP";
+ }
+ else {
+ throw std::invalid_argument("ZMQ socket type unknown");
+ }
+ ss << ")";
m_name = ss.str();
- m_zmq_pub_sock.bind(m_endpoint.c_str());
+ m_zmq_sock.bind(m_endpoint.c_str());
}
OutputZeroMQ::~OutputZeroMQ()
@@ -58,10 +70,16 @@ int OutputZeroMQ::process(Buffer* dataIn, Buffer* dataOut)
"(dataIn: %p, dataOut: %p)\n",
dataIn, dataOut);
- m_zmq_pub_sock.send(dataIn->getData(), dataIn->getLength());
+ if (m_type == ZMQ_REP) {
+ // A ZMQ_REP socket requires a request first
+ zmq::message_t msg;
+ m_zmq_sock.recv(&msg);
+ }
+
+ m_zmq_sock.send(dataIn->getData(), dataIn->getLength());
return dataIn->getLength();
}
-#endif // HAVE_OUTPUT_ZEROMQ_H
+#endif // HAVE_ZEROMQ