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