thesis/listings/event_handler_example.py

19 lines
558 B
Python
Raw Normal View History

2018-12-02 20:01:18 +00:00
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}'
}
}