|
|
@ -74,6 +74,14 @@ def webrtc_message(data): |
|
|
|
print("unknown message type") |
|
|
|
socketio.emit('message', data=data, room=ROOM, skip_sid=sid) |
|
|
|
|
|
|
|
@socketio.on('get_stats') |
|
|
|
def get_stats(data): |
|
|
|
sid = request.sid |
|
|
|
print("client %s requesting stats" % sid) |
|
|
|
from roberto import serial |
|
|
|
if sid != webrtccamera.sid: |
|
|
|
serial.add_callback('B', display_battery, sid) |
|
|
|
|
|
|
|
@socketio.on('disconnect') |
|
|
|
def disconnect(): |
|
|
|
sid = request.sid |
|
|
@ -81,8 +89,7 @@ def disconnect(): |
|
|
|
leave_room(ROOM) |
|
|
|
webrtccamera.disconnect_client(sid, ROOM) |
|
|
|
from roberto import serial |
|
|
|
if sid != webrtccamera.sid: |
|
|
|
serial.del_callback('B', display_battery) |
|
|
|
serial.del_callback('B', display_battery, sid) |
|
|
|
|
|
|
|
@socketio.on('connect') |
|
|
|
def connect(): |
|
|
@ -90,9 +97,6 @@ def connect(): |
|
|
|
print("Received Connect message from %s" % sid) |
|
|
|
join_room(ROOM) |
|
|
|
webrtccamera.connect_client(sid, ROOM) |
|
|
|
from roberto import serial |
|
|
|
if sid != webrtccamera.sid: |
|
|
|
serial.add_callback('B', display_battery) |
|
|
|
|
|
|
|
@socketio.on_error_default |
|
|
|
def default_error_handler(e): |
|
|
@ -103,6 +107,6 @@ def default_error_handler(e): |
|
|
|
for key in request: |
|
|
|
print('%s: %s' % (key, repr(request[key]))) |
|
|
|
|
|
|
|
def display_battery(val): |
|
|
|
socketio.emit('battery', data=val, room=ROOM) |
|
|
|
def display_battery(val, sid=ROOM): |
|
|
|
socketio.emit('battery', data=val, room=sid) |
|
|
|
#socketio.emit('battery', data=val) |
|
|
|