jonnydee / nzmqt

nzmqt - A lightweight C++ Qt binding for ZeroMQ
Other
199 stars 72 forks source link

receiving messages from PyZMQ #29

Closed FaisalZ closed 9 years ago

FaisalZ commented 9 years ago

I am trying to use the PUB/SUB pattern between a PyZMQ (python binding of zeroMQ) and nzmqt. But I am not able to subscribe to messages comming from PyZMQ since the string format of the messages differ. PyZMQ message: "topic message" nzmqt: "MSG[topic: message]" Is there a workaround for this or is it simply impossible to let PyZMQ and nzmqt talk to each other via PUB/SUB?

jonnydee commented 9 years ago

I think you are building upon an example, don't you? Because nzmqt itself does not restrict message topics to a certain pattern.

machinekoder commented 9 years ago

@FaisalZ We are using nzmqt and PyZMQ in Machinekit without problems: Take a look at https://github.com/machinekit/machinekit/blob/master/src/machinetalk/mkwrapper/mkwrapper.py#L1786 https://github.com/strahlex/QtQuickVcp/blob/master/src/application/qapplicationstatus.cpp#L393

EDIT: We are using XPUB on the server side to get noticed when someone subscribe. To encode message we use Google Protocol Buffers.

FaisalZ commented 9 years ago

Yes I used your PUB/SUB example as reference. How do you then subscribe to to a topic from a python server, that does not follow the mentioned message pattern of the example?

machinekoder commented 9 years ago

@FaisalZ nzmqt returns a list of QByteArrays containing the message parts. The first one is usually the topic, see my example above. https://github.com/strahlex/QtQuickVcp/blob/master/src/application/qapplicationstatus.cpp#L222

FaisalZ commented 9 years ago

Thanks for the comments. I got it working now. The "problem" was indeed that I thought the topic was not included in the normal message.