def notification(self, db_name: str): while not self.terminate: sio.sleep(1) sio.emit('DB Fetching', { 'data': 'db running', 'db_name': db_name }, namespace='/db_event')
def notify_failed(self, db_name): counter = 4 while counter: sio.sleep(1) sio.emit('DB Fetching', { 'data': 'db running', 'db_name': db_name, 'status': False }, namespace='/db_event') counter -= 1
def stop(self): if not self._data: return False self._data.update(defaultDict) r_remotePlayer.set( self._id, json.dumps(self._data), ) sio.emit( "remote_player", json.dumps({ "type": "action", "action": "stop" }), room=self._data["sid"], )
def pause(self): if not self._data: return False self._data.update({"status": 1}) r_remotePlayer.set( self._id, json.dumps(self._data), ) sio.emit( "remote_player", json.dumps({ "type": "action", "action": "pause" }), room=self._data["sid"], )
def seek(self, value: int): if not self._data: return False self._data.update({"position": value}) r_remotePlayer.set( self._id, json.dumps(self._data), ) sio.emit( "remote_player", json.dumps({ "type": "action", "data": value, "action": "seek", }), room=self._data["sid"], )
def remote_player(sid, message): playerID = getPlayerID(getUID(sid), message.get("name")) if message["action"] == "connect": if playerID is not None: data = {"sid": sid} data.update(defaultDict) r_remotePlayer.set( playerID, json.dumps(data), ) sio.emit( "remote_player", json.dumps({ "type": "status", "data": "ok", "action": message["action"] }), room=sid, ) else: sio.emit( "remote_player", json.dumps({ "type": "status", "data": "error", "action": message["action"] }), room=sid, ) elif message["action"] in ["status", "position"]: d = r_remotePlayer.get(playerID) if d: d = json.loads(d.decode("utf-8")) d[message["action"]] = message["data"] r_remotePlayer.set( playerID, json.dumps(d), )
def playMedia(self, mediaType: int, mediaData: str, args: dict = None) -> tuple: if self._data: playData = {"mediaType": mediaType, "mediaData": mediaData} playData.update(args) self._data.update({"mediaType": mediaType, "mediaData": mediaData}) r_remotePlayer.set( self._id, json.dumps(self._data), ) sio.emit( "remote_player", json.dumps({ "type": "action", "data": playData, "action": "playMedia", }), room=self._data["sid"], ) return {}, {}