thesis/listings/event_handler_example.py

19 lines
558 B
Python

from tfw import EventHandlerBase
class MyFirstEventHandler(EventHandlerBase):
def __init__(self):
super().__init__(self, key='fsm_update')
def handle_event(self, message):
print('I have received a message! Yaaay!')
# the return value of this method is automatically
# sent back to the TFW server
return {
'key': 'message',
'data': {
'originator': 'My first event handler',
'message': f'I have received this message: {message}'
}
}