browser-go-api/websockets/socket.py

25 lines
534 B
Python
Raw Normal View History

2019-10-07 23:28:11 +00:00
from app import socketio
from flask_socketio import send, emit
@socketio.on('connect')
def handle_connection():
print('''
wow, there was a socketio connection!
cool
''')
2019-10-08 23:56:28 +00:00
emit('message', {'data':'connection'})
2019-10-07 23:28:11 +00:00
@socketio.on('message')
def handle_message(message):
print(message)
2019-10-08 23:56:28 +00:00
emit('message return', {'message':'a message was sent'}, broadcast=True)
@socketio.on('connect', namespace='/newroom')
def handle_connection():
print('''
look cool a namespaced socketio connection!
''')