ws库再升级
This commit is contained in:
@@ -93,7 +93,7 @@ do--Connect
|
|||||||
else
|
else
|
||||||
readCHN:push(err)
|
readCHN:push(err)
|
||||||
end
|
end
|
||||||
SOCK:settimeout(0)
|
SOCK:settimeout(6.26)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -125,9 +125,20 @@ while true do--Running
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Receive data
|
--Receive data
|
||||||
res=SOCK:receive(length)
|
res=""
|
||||||
|
while length>0 do
|
||||||
|
local t=SOCK:receive(length)
|
||||||
|
if t then
|
||||||
|
res=res..t
|
||||||
|
length=length-#t
|
||||||
|
else--Time out!
|
||||||
|
res=false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--React
|
--React
|
||||||
|
if res then
|
||||||
if op==8 then--8=close
|
if op==8 then--8=close
|
||||||
readCHN:push(op)
|
readCHN:push(op)
|
||||||
SOCK:close()
|
SOCK:close()
|
||||||
@@ -137,20 +148,32 @@ while true do--Running
|
|||||||
else
|
else
|
||||||
readCHN:push("Server Error")
|
readCHN:push("Server Error")
|
||||||
end
|
end
|
||||||
elseif op==0 then
|
elseif op==0 then--0=continue
|
||||||
buffer=buffer..res
|
buffer=buffer..res
|
||||||
if fin then
|
if fin then
|
||||||
|
-- print("FIN=1 (c")
|
||||||
readCHN:push(buffer)
|
readCHN:push(buffer)
|
||||||
buffer=""
|
buffer=""
|
||||||
|
else
|
||||||
|
-- print("FIN=0 (c")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
readCHN:push(op)
|
readCHN:push(op)
|
||||||
if fin then
|
if fin then
|
||||||
|
-- print("OP: "..op.."\tFIN=1")
|
||||||
readCHN:push(res)
|
readCHN:push(res)
|
||||||
else
|
else
|
||||||
|
-- print("OP: "..op.."\tFIN=0")
|
||||||
buffer=res
|
buffer=res
|
||||||
|
-- print("START pack: "..res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
--TIMEOUT
|
||||||
|
SOCK:close()
|
||||||
|
readCHN:push(8)
|
||||||
|
readCHN:push("WS time out")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|||||||
Reference in New Issue
Block a user