From 068e227e22c816644baf72d7fef099dca1303db4 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Fri, 9 Jun 2023 23:16:16 +0200 Subject: [PATCH] ii --- main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 9e0c842..d98b2a4 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ import queue from flask import Flask, render_template, request, make_response, session -from flask_socketio import SocketIO #https://pythonprogramminglanguage.com/python-flask-websocket/ +from flask_socketio import SocketIO, join_room, leave_room #https://pythonprogramminglanguage.com/python-flask-websocket/ from flask_session import Session import sqlite3 import time @@ -107,16 +107,17 @@ def get_addtag_request(): @socketio.on('addtag') def request_addtag(data): global finished + join_room(session[id]) if len(users.queue) > 0: user = users.queue[len(users.queue) - 1] if user == [data["data"], "add", session[id]]: - socketio.emit("wait", "wait") + socketio.emit("wait", "wait", to=session[id]) i = 0 while finished != [data["data"], "add", 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: @@ -125,9 +126,9 @@ def request_addtag(data): username = c.fetchall()[0][1] c.execute(f"SELECT * FROM tags WHERE userid={user}") tag_id = c.fetchall()[0][0] - socketio.emit("finished", f"Added {tag_id} to {username}") + socketio.emit("finished", f"Added {tag_id} to {username}", to=session[id]) else: - socketio.emit("busy", "busy") + socketio.emit("busy", "busy", to=session[id]) else: socketio.emit("error", "error")