修补ws模块

This commit is contained in:
MrZ626
2021-03-05 21:07:50 +08:00
parent 0bf4642f10
commit d824b87b17

View File

@@ -74,14 +74,19 @@ do--Connect
local l=SOCK:receive("*l") local l=SOCK:receive("*l")
local code=l:find(" "); code=l:sub(code+1,code+3) local code=l:find(" "); code=l:sub(code+1,code+3)
if code=="200"then if code=="101"then
readCHN:push("success") readCHN:push("success")
else else
local ctLen
repeat repeat
l=SOCK:receive("*l") l=SOCK:receive("*l")
if not ctLen and l:find"Length"then
ctLen=tonumber(l:match"%d+")
end
until l=="" until l==""
l=SOCK:receive("*l") l=SOCK:receive(ctLen)
local reason=JSON.decode(l)if reason then reason=reason.message end local reason=JSON.decode(l)
if reason then reason=reason.message end
readCHN:push(code.."-"..(reason or l)) readCHN:push(code.."-"..(reason or l))
end end
else else