ii
This commit is contained in:
parent
e2e7abbe8a
commit
068e227e22
1 changed files with 6 additions and 5 deletions
11
main.py
11
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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue