@ -413,7 +413,7 @@ class WebRTCCamera(Thread):
else:
print("Unknown message \"%s\", ignoring" % data['data'])
@sio.event
@sio.on('connect')
def connected():
print("I'm connected!")
@ -421,7 +421,7 @@ class WebRTCCamera(Thread):
def connect_error():
print("The connection failed!")
@sio.on('disconnect')
def disconnected():
print("I'm disconnected!")
@ -225,6 +225,12 @@ function getConnectionStats() {
var statsInterval = window.setInterval(getConnectionStats, 1000);
setInterval(function(){
if (socket.connected) {
socket.emit('ping');
}
}, 5000);
</script>
<script src="{{ url_for('frontend.gamepad_js') }}"></script>
@ -111,6 +111,11 @@ def connect():
if sid != webrtccamera.sid:
serial.add_callback('B', display_battery)
@socketio.on('ping', namespace='/webrtc')
def ping():
sid = request.sid
print("Received ping from %s" % sid)
@socketio.on_error_default
def default_error_handler(e):
print(request.event["message"]) # "my error event"