From 48ced08615de5290739ec12aff8569ed1db7f9c3 Mon Sep 17 00:00:00 2001 From: Jon Nordby Date: Sat, 6 May 2017 03:52:45 +0200 Subject: [PATCH] Participant.send(): Support sending bytearray as a binary blob --- msgflo/msgflo.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/msgflo/msgflo.py b/msgflo/msgflo.py index 6ff67e9..498fdfb 100755 --- a/msgflo/msgflo.py +++ b/msgflo/msgflo.py @@ -137,8 +137,11 @@ def nack_message(self, msg): def _send(self, outport, data): ports = self.participant.definition['outports'] logger.debug("Publishing to message: %s, %s, %s" % (data,outport,ports)) - serialized = json.dumps(data) - msg = haigha_Message(serialized) + if isinstance(data, bytearray): + pass + else: + data = json.dumps(data) + msg = haigha_Message(data) port = [p for p in ports if outport == p['id']][0] self._channel.basic.publish(msg, port['queue'], '') return @@ -231,11 +234,14 @@ def run(self): def _send(self, outport, data): ports = self.participant.definition['outports'] - serialized = json.dumps(data) + if isinstance(data, bytearray): + pass + else + data = json.dumps(data) port = [p for p in ports if outport == p['id']][0] queue = port['queue'] logger.debug("Publishing message on %s" % (queue)) - self._client.publish(queue, serialized) + self._client.publish(queue, data) # TODO: implement ACK/NACK for MQTT def ack_message(self, msg):