Hendrik Langer 4 years ago
parent
commit
cb0fd88a01
  1. 2
      raspberry/roberto/__init__.py
  2. 4
      raspberry/roberto/views/websocket/routes.py

2
raspberry/roberto/__init__.py

@ -55,7 +55,7 @@ def initialize_extensions(app):
from roberto.model import db from roberto.model import db
db.init_app(app) db.init_app(app)
#login.init_app(app) #login.init_app(app)
socketio.init_app(app, cors_allowed_origins="*") socketio.init_app(app, cors_allowed_origins="*", engineio_logger=True)
pass pass
def register_blueprints(app): def register_blueprints(app):

4
raspberry/roberto/views/websocket/routes.py

@ -89,7 +89,10 @@ def disconnect():
leave_room(ROOM) leave_room(ROOM)
webrtccamera.disconnect_client(sid, ROOM) webrtccamera.disconnect_client(sid, ROOM)
from roberto import serial from roberto import serial
try:
serial.del_callback('B', display_battery, sid) serial.del_callback('B', display_battery, sid)
except:
pass
@socketio.on('connect') @socketio.on('connect')
def connect(): def connect():
@ -108,5 +111,6 @@ def default_error_handler(e):
print('%s: %s' % (key, repr(request[key]))) print('%s: %s' % (key, repr(request[key])))
def display_battery(val, sid=ROOM): def display_battery(val, sid=ROOM):
print("sending battery value %s to client %s" % (val, sid))
socketio.emit('battery', data=val, room=sid) socketio.emit('battery', data=val, room=sid)
#socketio.emit('battery', data=val) #socketio.emit('battery', data=val)

Loading…
Cancel
Save