Compare commits

..

No commits in common. "96a91c4154d4f34eb0c40920db3d6d20b70b2fb1" and "46ae52a537405e2fdc35dafcbff06d0632ee1c00" have entirely different histories.

2 changed files with 4 additions and 6 deletions

4
app.py
View File

@ -40,9 +40,9 @@ if __name__ == "__main__":
generateduuid = str(uuid.uuid4()) generateduuid = str(uuid.uuid4())
communicator = Communicator(currentconsumer=KNOWNCONSUMER, uuid=generateduuid) communicator = Communicator(currentconsumer=KNOWNCONSUMER, uuid=generateduuid)
LOGGER.debug(f"My uuid is {generateduuid}") LOGGER.debug(f"My uuid is {generateduuid}")
messagesender = MessageSender(communicator=communicator, uuid=generateduuid)
consumerlocator = ConsumerLocator(uuid=generateduuid, communicator=communicator, consumerlocator = ConsumerLocator(uuid=generateduuid, communicator=communicator,
redisconnector=RedisConnector()) redisconnector=RedisConnector())
messagesender = MessageSender(communicator=communicator)
consumerlocator.learnconsumerlist() consumerlocator.learnconsumerlist()
while True: while True:

View File

@ -7,7 +7,6 @@ Message sender component.
import logging import logging
import random import random
import string import string
import json
from communicator import Communicator from communicator import Communicator
__author__ = "@kovacsbence" __author__ = "@kovacsbence"
@ -24,14 +23,13 @@ class MessageSender:
Component responsible for sending the messages. Requires an instance of :class:`communicator.Communicator`. Component responsible for sending the messages. Requires an instance of :class:`communicator.Communicator`.
""" """
def __init__(self, communicator: Communicator, uuid: str): def __init__(self, communicator: Communicator):
"""**Constructor:** """**Constructor:**
Initializes the object. Initializes the object.
:param communicator: an instance of :class:`communicator.Communicator`. :param communicator: an instance of :class:`communicator.Communicator`.
""" """
self.communicator = communicator self.communicator = communicator
self.uuid = uuid
def randomstring(self, stringlength: int) -> str: def randomstring(self, stringlength: int) -> str:
"""Generate a random string of fixed length """Generate a random string of fixed length
@ -56,4 +54,4 @@ class MessageSender:
data = self.randomstring(32) data = self.randomstring(32)
else: else:
data = message data = message
self.communicator.sendmessage(json.dumps({"message": data, "uuid": self.uuid})) self.communicator.sendmessage(data)