Fix for hv1 and 2 playing files for hv10/11 etc
This commit is contained in:
parent
b2a378acfe
commit
245946de34
1 changed files with 9 additions and 3 deletions
|
@ -8,7 +8,13 @@ mainLogger = logging.getLogger("hugvey")
|
|||
LOG_BS = 5
|
||||
|
||||
def getTopic(hugvey_id):
|
||||
return "hv{}".format(hugvey_id)
|
||||
if hugvey_id > 99:
|
||||
raise Exception("Incompatible with hugvey id > 99")
|
||||
|
||||
# We will have to zero-fill the number (01 instead of 1), because of how zmq
|
||||
# topic subscription works: subscribing to hv1 also brings in messages for
|
||||
# hv10 hv11 and hv1whatever, hence only hv01, hv02 etc is unique
|
||||
return "hv{:02}".format(hugvey_id)
|
||||
|
||||
|
||||
def zmqSend(socket, hugvey_id, msg):
|
||||
|
@ -21,8 +27,8 @@ def zmqSend(socket, hugvey_id, msg):
|
|||
|
||||
async def zmqReceive(socket):
|
||||
topic, msg = await socket.recv_multipart()
|
||||
hugvey_id = topic.decode()[2:]
|
||||
hugvey_id = int(topic.decode()[2:])
|
||||
mainLogger.getChild("{}".format(hugvey_id)).getChild("communication").debug(
|
||||
"Received 0mq messages for Hugvey #{} containing {}".format(hugvey_id, msg.decode())
|
||||
)
|
||||
return int(hugvey_id), json.loads(msg.decode())
|
||||
return hugvey_id, json.loads(msg.decode())
|
||||
|
|
Loading…
Reference in a new issue