升级task模块和使用模块的网络相关函数,ws连接任务不再与未完成的http请求冲突
This commit is contained in:
@@ -5,6 +5,7 @@ local tasks={}
|
||||
|
||||
local TASK={
|
||||
netTaskCount=0,
|
||||
wsConnecting=false,
|
||||
}
|
||||
function TASK.getCount()
|
||||
return #tasks
|
||||
@@ -17,7 +18,10 @@ function TASK.update()
|
||||
if T.net then
|
||||
TASK.netTaskCount=TASK.netTaskCount-1
|
||||
end
|
||||
rem(tasks,i)
|
||||
if T.ws then
|
||||
TASK.wsConnecting=false
|
||||
end
|
||||
rem(tasks,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -44,6 +48,20 @@ function TASK.newNet(code,...)
|
||||
}
|
||||
end
|
||||
end
|
||||
function TASK.newWS(code,...)
|
||||
TASK.wsConnecting=true
|
||||
local thread=ct.create(code)
|
||||
ct.resume(thread,...)
|
||||
if ct.status(thread)~="dead"then
|
||||
tasks[#tasks+1]={
|
||||
thread=thread,
|
||||
code=code,
|
||||
args={...},
|
||||
net=true,
|
||||
ws=true,
|
||||
}
|
||||
end
|
||||
end
|
||||
function TASK.removeTask_code(code)
|
||||
for i=#tasks,1,-1 do
|
||||
if tasks[i].code==code then
|
||||
|
||||
Reference in New Issue
Block a user