1
0
Fork 0
forked from bton/matekasse

room specifik socketio emit

This commit is contained in:
2000-Trek 2023-06-09 23:19:11 +02:00
parent 068e227e22
commit 46323b0ef4

13
main.py
View file

@ -130,7 +130,8 @@ def request_addtag(data):
else:
socketio.emit("busy", "busy", to=session[id])
else:
socketio.emit("error", "error")
socketio.emit("error", "error", to=session[id])
leave_room(session[id])
@app.route("/removetag", methods=['GET'])
def get_removetag_request():
@ -147,18 +148,19 @@ def get_removetag_request():
@socketio.on('removetag')
def request_removetag(data):
global finished
join_room(session[id])
if len(users.queue) > 0:
user = users.queue[len(users.queue) - 1]
print(user)
print(session[id])
if user == [data["data"], "remove", session[id]]:
socketio.emit("wait", "wait")
socketio.emit("wait", "wait", to=session[id])
i = 0
while finished != [data["data"], "remove", session[id]]:
time.sleep(1)
i += 1
if i > 20:
socketio.emit("error", "timeout")
socketio.emit("error", "timeout", to=session[id])
notimportant = users.get()
break
else:
@ -169,9 +171,10 @@ def request_removetag(data):
tag_id = c.fetchall()[0][0]
socketio.emit("finished", f"removed {tag_id} from {username}")
else:
socketio.emit("busy", "busy")
socketio.emit("busy", "busy", to=session[id])
else:
socketio.emit("error", "error")
socketio.emit("error", "error", to=session[id])
leave_room(session[id])
#api
@app.route("/api/tag_id", methods=['GET'])