|
|
@ -10,23 +10,7 @@ from roberto import socketio |
|
|
|
#### routes #### |
|
|
|
################ |
|
|
|
|
|
|
|
@socketio.on('my_event', namespace='/test') |
|
|
|
def test_message(message): |
|
|
|
emit('my response', {'data': message['data']}) |
|
|
|
|
|
|
|
@socketio.on('my broadcast event', namespace='/test') |
|
|
|
def test_message(message): |
|
|
|
emit('my response', {'data': message['data']}, broadcast=True) |
|
|
|
|
|
|
|
@socketio.on('connect', namespace='/test') |
|
|
|
def test_connect(): |
|
|
|
emit('my response', {'data': 'Connected'}) |
|
|
|
|
|
|
|
@socketio.on('disconnect', namespace='/test') |
|
|
|
def test_disconnect(): |
|
|
|
print('Client disconnected') |
|
|
|
|
|
|
|
@socketio.on('axes', namespace='/gamepad') |
|
|
|
@socketio.on('axes') |
|
|
|
def gamepad_axes(axes_data): |
|
|
|
print('GAMEPAD axes') |
|
|
|
print(axes_data) |
|
|
@ -53,7 +37,7 @@ def applyDeadZone(value, threshold): |
|
|
|
new_value = new_value * -1 |
|
|
|
return new_value |
|
|
|
|
|
|
|
@socketio.on('text', namespace='/gamepad') |
|
|
|
@socketio.on('text') |
|
|
|
def display_text(text): |
|
|
|
print("display_text()") |
|
|
|
print(text['data']) |
|
|
@ -73,7 +57,7 @@ ROOM = 'default' |
|
|
|
def camera(): |
|
|
|
return render_template('camera.html', room=ROOM) |
|
|
|
|
|
|
|
@socketio.on('message', namespace='/webrtc') # ok |
|
|
|
@socketio.on('message') # ok |
|
|
|
def webrtc_message(data): |
|
|
|
sid = request.sid |
|
|
|
print('Message from {}: {}'.format(sid, data)) |
|
|
@ -88,15 +72,9 @@ def webrtc_message(data): |
|
|
|
data['from_sid'] = sid |
|
|
|
else: |
|
|
|
print("unknown message type") |
|
|
|
socketio.emit('message', data=data, room=ROOM, namespace='/webrtc', skip_sid=sid) |
|
|
|
|
|
|
|
@socketio.on('ping_message', namespace='/webrtc') |
|
|
|
def ping_message(data): |
|
|
|
sid = request.sid |
|
|
|
print("Received ping from %s" % sid) |
|
|
|
socketio.emit('ping_message', data={ 'type':'pong' }, room=sid, namespace='/webrtc') |
|
|
|
socketio.emit('message', data=data, room=ROOM, skip_sid=sid) |
|
|
|
|
|
|
|
@socketio.on('disconnect', namespace='/webrtc') |
|
|
|
@socketio.on('disconnect') |
|
|
|
def disconnect(): |
|
|
|
sid = request.sid |
|
|
|
print("Received Disconnect message from %s" % sid) |
|
|
@ -106,7 +84,7 @@ def disconnect(): |
|
|
|
if sid != webrtccamera.sid: |
|
|
|
serial.del_callback('B', display_battery) |
|
|
|
|
|
|
|
@socketio.on('connect', namespace='/webrtc') |
|
|
|
@socketio.on('connect') |
|
|
|
def connect(): |
|
|
|
sid = request.sid |
|
|
|
print("Received Connect message from %s" % sid) |
|
|
@ -126,5 +104,5 @@ def default_error_handler(e): |
|
|
|
print('%s: %s' % (key, repr(request[key]))) |
|
|
|
|
|
|
|
def display_battery(val): |
|
|
|
socketio.emit('battery', data=val, room=ROOM, namespace='/webrtc') |
|
|
|
socketio.emit('battery', data=val, namespace='/webrtc') |
|
|
|
socketio.emit('battery', data=val, room=ROOM) |
|
|
|
#socketio.emit('battery', data=val) |
|
|
|