43 lines
864 B
Python
43 lines
864 B
Python
# Copyright (c) 2019. Tobias Kurze
|
|
|
|
import logging
|
|
from flask_socketio import SocketIO, emit
|
|
|
|
from backend import app
|
|
|
|
logging.basicConfig()
|
|
|
|
socketio = SocketIO(app)
|
|
|
|
|
|
@socketio.on('my_event')
|
|
def test_message(message: dict):
|
|
print("received msg!")
|
|
print(message)
|
|
# emit('my_event', {'data': message['data']})
|
|
|
|
|
|
@socketio.on('my broadcast event', namespace='/')
|
|
def test_message(message):
|
|
emit('my response', {'data': message['data']}, broadcast=True)
|
|
|
|
|
|
@socketio.on('connect')
|
|
def test_connect():
|
|
print("connected")
|
|
emit('connect', "antwort")
|
|
|
|
|
|
@socketio.on('disconnect', namespace='/')
|
|
def test_disconnect():
|
|
print('Client disconnected')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print("running main")
|
|
socketio.init_app(app, cors_allowed_origins="*")
|
|
socketio.run(app, host="localhost", port=5000)
|
|
# ENDE
|
|
|
|
print("runnung?!")
|