Browse Source

bring back rooms

split-pipe
Hendrik Langer 4 years ago
parent
commit
6211555b8f
  1. 4
      raspberry/roberto/camera/camera_gstreamer_webrtc.py
  2. 10
      raspberry/roberto/views/websocket/routes.py

4
raspberry/roberto/camera/camera_gstreamer_webrtc.py

@ -88,12 +88,12 @@ class WebRTCCamera(Thread):
self.connected = False
sio.disconnect()
def connect_client(self, sid):
def connect_client(self, sid, room):
if not self.is_alive():
self.start()
self._queue.put({'job':'connect_client', 'sid':sid})
def disconnect_client(self, sid):
def disconnect_client(self, sid, room):
self._queue.put({'job':'disconnect_client', 'sid':sid})
def start_pipeline(self, client_sid): # ok

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

@ -61,26 +61,28 @@ ROOM = 'default'
@websocket_blueprint.route('/camera')
def camera():
return render_template('camera.html', room='default')
return render_template('camera.html', room=ROOM)
@socketio.on('message', namespace='/webrtc') # ok
def webrtc_message(data):
sid = request.sid
print('Message from {}: {}'.format(sid, data))
socketio.emit('message', data=data, namespace='/webrtc', skip_sid=sid)
socketio.emit('message', data=data, room=ROOM, namespace='/webrtc', skip_sid=sid)
@socketio.on('disconnect', namespace='/webrtc')
def disconnect():
sid = request.sid
print("Received Disconnect message from %s" % sid)
webrtccamera.disconnect_client(sid)
leave_room(ROOM)
webrtccamera.disconnect_client(sid, ROOM)
@socketio.on('connect', namespace='/webrtc')
def connect():
sid = request.sid
print("Received Connect message from %s" % sid)
webrtccamera.connect_client(sid)
join_room(ROOM)
webrtccamera.connect_client(sid, ROOM)
@socketio.on_error_default
def default_error_handler(e):

Loading…
Cancel
Save