Exemplo n.º 1
0
 def publish(self, topic, message):
     self.out_sock.send(msg.encode(topic, message))
Exemplo n.º 2
0
def rename_message(msg_buf, topic, new_topic):
    msg_topic, msg_body = msg.decode(msg_buf)
    renamed_buf = msg.encode(msg_topic.replace(topic, new_topic, 1), msg_body)
    return renamed_buf
Exemplo n.º 3
0
def rename_message(msg_buf, topic, new_topic):
    msg_topic, msg_body = msg.decode(msg_buf)
    renamed_buf = msg.encode(msg_topic.replace(topic, new_topic, 1), msg_body)
    return renamed_buf
Exemplo n.º 4
0
 def test_rename(self):
     buf = zmqmsgbus.rename_message(msg.encode('/old/topic', 123),
                                    '/old/', '/new/')
     self.assertEqual(('/new/topic', 123), msg.decode(buf))
Exemplo n.º 5
0
 def test_encode(self):
     self.assertEqual(b'hello\0'+msgpack.packb(123),
                      msg.encode('hello', 123))
Exemplo n.º 6
0
 def test_decode(self):
     self.assertEqual(('hello', [1, 2, 3]),
                      msg.decode(msg.encode('hello', [1, 2, 3])))
Exemplo n.º 7
0
 def publish(self, topic, message):
     self.out_sock.send(msg.encode(topic, message))