Skip to content

Commit

Permalink
Merge pull request machinekit#28 from grefab/master
Browse files Browse the repository at this point in the history
Added methods to unbind, disconnect and configure high watermarks to ZMQSocket
  • Loading branch information
jonnydee committed Nov 16, 2014
2 parents 0dc6b20 + e8f196a commit 8f71eac
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
30 changes: 30 additions & 0 deletions include/nzmqt/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ NZMQT_INLINE void ZMQSocket::bindTo(const char *addr_)
bind(addr_);
}

NZMQT_INLINE void ZMQSocket::unbindFrom(const QString& addr_)
{
unbind(addr_.toLocal8Bit());
}

NZMQT_INLINE void ZMQSocket::unbindFrom(const char *addr_)
{
unbind(addr_);
}

NZMQT_INLINE void ZMQSocket::connectTo(const QString& addr_)
{
zmqsuper::connect(addr_.toLocal8Bit());
Expand All @@ -181,6 +191,16 @@ NZMQT_INLINE void ZMQSocket::connectTo(const char* addr_)
zmqsuper::connect(addr_);
}

NZMQT_INLINE void ZMQSocket::disconnectFrom(const QString& addr_)
{
zmqsuper::disconnect(addr_.toLocal8Bit());
}

NZMQT_INLINE void ZMQSocket::disconnectFrom(const char* addr_)
{
zmqsuper::disconnect(addr_);
}

NZMQT_INLINE bool ZMQSocket::sendMessage(ZMQMessage& msg_, SendFlags flags_)
{
return send(msg_, flags_);
Expand Down Expand Up @@ -335,6 +355,16 @@ NZMQT_INLINE void ZMQSocket::unsubscribeFrom(const QByteArray& filter_)
setOption(OPT_UNSUBSCRIBE, filter_);
}

NZMQT_INLINE void ZMQSocket::setSendHighWaterMark(int value_)
{
setOption(OPT_SNDHWM, value_);
}

NZMQT_INLINE void ZMQSocket::setReceiveHighWaterMark(int value_)
{
setOption(OPT_RCVHWM, value_);
}



/*
Expand Down
16 changes: 15 additions & 1 deletion include/nzmqt/nzmqt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ namespace nzmqt
OPT_LINGER = ZMQ_LINGER,
OPT_RECONNECT_IVL = ZMQ_RECONNECT_IVL,
OPT_RECONNECT_IVL_MAX = ZMQ_RECONNECT_IVL_MAX,
OPT_BACKLOG = ZMQ_BACKLOG
OPT_BACKLOG = ZMQ_BACKLOG,
OPT_SNDHWM = ZMQ_SNDHWM,
OPT_RCVHWM = ZMQ_RCVHWM
};

~ZMQSocket();
Expand All @@ -203,10 +205,18 @@ namespace nzmqt

void bindTo(const char *addr_);

void unbindFrom(const QString& addr_);

void unbindFrom(const char *addr_);

void connectTo(const QString& addr_);

void connectTo(const char* addr_);

void disconnectFrom(const QString& addr_);

void disconnectFrom(const char* addr_);

bool sendMessage(ZMQMessage& msg_, SendFlags flags_ = SND_NOBLOCK);

// Receives a message or a message part.
Expand Down Expand Up @@ -257,6 +267,10 @@ namespace nzmqt

void unsubscribeFrom(const QByteArray& filter_);

void setSendHighWaterMark(int value_);

void setReceiveHighWaterMark(int value_);

signals:
void messageReceived(const QList<QByteArray>&);

Expand Down

0 comments on commit 8f71eac

Please sign in to comment.