24 lines
500 B
Python
24 lines
500 B
Python
|
#!/usr/bin/env python3
|
||
|
"""
|
||
|
Individual functions for handling WebSocket events. Gets called by the
|
||
|
QuestConsumer object in consumers.py.
|
||
|
"""
|
||
|
import types
|
||
|
|
||
|
def message(socket, data):
|
||
|
"""
|
||
|
Gets called when the server receives a 'message' event.
|
||
|
"""
|
||
|
message = data.get('message')
|
||
|
print(message)
|
||
|
|
||
|
data = {}
|
||
|
data['message'] = message.upper()
|
||
|
socket.send('message', data)
|
||
|
|
||
|
|
||
|
events = {}
|
||
|
for obj in dir():
|
||
|
if type(locals()[obj]) == types.FunctionType:
|
||
|
events[locals()[obj].__name__] = locals()[obj]
|