From be254e75941721689be36df0305da720bc522b42 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sun, 7 Nov 2021 15:16:14 +0000 Subject: [PATCH] Gateway -> Monitor now working We literally weren't making use of the 'topic' in the message. Thus, so as to avoid issues with trying to mash a string topic together with a bytes (compressed) message, I've ripped that out. --- src/eddn/Gateway.py | 6 ++---- src/eddn/Monitor.py | 13 +------------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index 3bcbb61..5fe2526 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -135,11 +135,9 @@ def push_message(parsed_message: Dict, topic: str) -> None: # Push a zlib compressed JSON representation of the message to # announcers with schema as topic - compressed_msg = zlib.compress(string_message) + compressed_message = zlib.compress(string_message) - send_message = f"{str(topic)!r} |-| {compressed_msg!r}".encode('utf8') - - sender.send(send_message) + sender.send(compressed_message) stats_collector.tally("outbound") diff --git a/src/eddn/Monitor.py b/src/eddn/Monitor.py index 9b01b49..823b7a8 100644 --- a/src/eddn/Monitor.py +++ b/src/eddn/Monitor.py @@ -210,23 +210,12 @@ class Monitor(Thread): database=Settings.MONITOR_DB['database'] ) - # Separate topic from message - message_split = message.split(b' |-| ') - - # Handle gateway not sending topic - if len(message_split) > 1: - message = message_split[1] - else: - message = message_split[0] - - print(f'message: {message}') message_text = zlib.decompress(message) json = simplejson.loads(message_text) # Default variables schema_id = json['$schemaRef'] - software_id = json['header']['softwareName'].encode('utf8') + ' | ' \ - + json['header']['softwareVersion'].encode('utf8') + software_id = f'{json["header"]["softwareName"]} | {json["header"]["softwareVersion"]}' # Duplicates? if Settings.RELAY_DUPLICATE_MAX_MINUTES: