From 46323b0ef48c00075928d57a90eb94ee28fe7d9d Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Fri, 9 Jun 2023 23:19:11 +0200 Subject: [PATCH] room specifik socketio emit --- main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index d98b2a4..c7d4143 100644 --- a/main.py +++ b/main.py @@ -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'])