From 16dad5e2cd5bdc2ba3e38afd7521d7e59c0d42f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Bokros?= Date: Mon, 29 Jan 2018 16:48:32 +0100 Subject: [PATCH] Add initial version of MessageSender --- src/event_handlers/message_sender.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/event_handlers/message_sender.py diff --git a/src/event_handlers/message_sender.py b/src/event_handlers/message_sender.py new file mode 100644 index 0000000..e780c92 --- /dev/null +++ b/src/event_handlers/message_sender.py @@ -0,0 +1,14 @@ +from server_connector import ServerUplinkConnector + + +class MessageSender: + def __init__(self, custom_anchor=None): + self.server_connector = ServerUplinkConnector() + if isinstance(custom_anchor, str): + custom_anchor = custom_anchor.encode('utf-8') + self.anchor = custom_anchor or b'message' + + def send(self, message): + if isinstance(message, str): + message = message.encode('utf-8') + self.server_connector.send(self.anchor, message)