mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:41:32 +00:00
Add initial version of MessageSender
This commit is contained in:
parent
cd5f7084da
commit
16dad5e2cd
14
src/event_handlers/message_sender.py
Normal file
14
src/event_handlers/message_sender.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user