Skip to content Skip to sidebar Skip to footer

Setting The Topic When Using The Pyobj Subfunctions In Zeromq/python

I have been looking at zeromq and i noticed there were socket.send_pyobj() and socket.recv_pyobj() functions. My question is how would one set the topic for PUB/SUB if they called

Solution 1:

NVM. figured out how to do it. I should use send_multipart if i want the topic and msg viewed as one and also filter the object.

For the publisher.

   self.socket.send_multipart([b'status',pickle.dumps(msg2)])

For the reciver.

    socket.setsockopt(zmq.SUBSCRIBE, 'status')
    [topic,msg] = socket.recv_multipart()
    msg2 = pickle.loads(msg)
    print msg2['game']

I don't know why but if you use their example. http://zguide.zeromq.org/py:psenvsub it shows i should do b'status' on the socketopt but it didnt filter if i did it that wya.

Post a Comment for "Setting The Topic When Using The Pyobj Subfunctions In Zeromq/python"