"version bump" lol

This commit is contained in:
Fierelier 2021-04-09 23:46:19 +02:00
parent b6dca2e255
commit 1d58d87ef4
3 changed files with 36 additions and 12 deletions

View File

@ -82,7 +82,7 @@ def sendResponse(connection,data):
senderThreadSleepMin = 0.0333
senderThreadSleepMax = 1.0
senderThreadSleepIncr = 0.05
senderThreadSleepIncr = 0.01
class senderThread(threading.Thread):
def __init__(self,connectionThread):
@ -110,7 +110,7 @@ class senderThread(threading.Thread):
with self.lock:
sleepTime = self.sleep
print(sleepTime)
#print(sleepTime)
time.sleep(sleepTime)
with self.lock:
@ -153,8 +153,11 @@ class connectionThread(threading.Thread):
print("thread closed: " +str(self.threadId)+ " (open: " +str(len(threads))+ ")")
self.closed = True
def sendResponse(self,data):
with self.lock:
def sendResponse(self,data,lock = True):
if lock == True:
with self.lock:
self.senderThread.addToQueue([sendResponse,[self.connection,data],{}])
else:
self.senderThread.addToQueue([sendResponse,[self.connection,data],{}])
def run(self):

View File

@ -0,0 +1,29 @@
moduleDepends([
p("[text server]","[api]","commands"),
])
global textSend
def textSend(self,command,args):
if len(args) < 2:
return ["error","nonfatal","syntax","Correct syntax: " +command+ ",<user>,<command>,[argument 1],[argument 2],..."]
user = args[0].lower()
if len(user) < 1:
return ["error","nonfatal","name_too_short","Needs to be at least 1 character in length."]
me = ""
with self.lock:
me = self.user
if not me:
return ["error","nonfatal","not_logged_in"]
with threadsLock:
for threadId in threads:
thread = threads[threadId]
with thread.lock:
if thread.user != user: continue
thread.sendResponse(textListToCommand(["send",me] + args[1:]).encode("utf-8"),lock = False)
return ["ok"]
textCommandAddHandler("send",textSend)

View File

@ -33,14 +33,6 @@ def textOnRequest(event,self,requestLength):
text = data.decode("utf-8")
print(":".join(map(str,self.address))+ " > " +text)
if text == "close":
with threadsLock:
global close
close = True
self.closeThread()
return True
response = textCommandRun(self,textCommandToList(text))
print("response: " +textListToCommand(response))
self.sendResponse(textListToCommand(response).encode("utf-8"))