mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-14 16:57:16 +00:00
22 lines
671 B
Python
22 lines
671 B
Python
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
|
# All Rights Reserved. See LICENSE file for details.
|
|
|
|
from datetime import datetime
|
|
|
|
from tfw.networking.event_handlers import ServerUplinkConnector
|
|
|
|
|
|
class MessageSender:
|
|
def __init__(self, custom_key: str = None):
|
|
self.server_connector = ServerUplinkConnector()
|
|
self.key = custom_key or 'message'
|
|
|
|
def send(self, originator, message):
|
|
data = {
|
|
'originator': originator,
|
|
'timestamp': datetime.now().isoformat(),
|
|
'message': message
|
|
}
|
|
self.server_connector.send({'key': self.key,
|
|
'data': data})
|