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