修复ws库分包消息解析错误
This commit is contained in:
@@ -110,6 +110,8 @@ local _send do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local res,err
|
||||||
|
local op,fin
|
||||||
local length
|
local length
|
||||||
local lBuffer=""--Long multi-data buffer
|
local lBuffer=""--Long multi-data buffer
|
||||||
local UFF--Un-finished-frame mode
|
local UFF--Un-finished-frame mode
|
||||||
@@ -125,25 +127,13 @@ while true do--Running
|
|||||||
|
|
||||||
--Read
|
--Read
|
||||||
while true do
|
while true do
|
||||||
if UFF then--UNF process
|
if not UFF then--UNF process
|
||||||
local s,e,p=SOCK:receive(length)
|
|
||||||
if s then
|
|
||||||
sBuffer=sBuffer..s
|
|
||||||
UFF=false
|
|
||||||
elseif p then
|
|
||||||
sBuffer=sBuffer..p
|
|
||||||
length=length-#p
|
|
||||||
if length==0 then
|
|
||||||
UFF=false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
--Byte 0-1
|
--Byte 0-1
|
||||||
local res,err=SOCK:receive(2)
|
res,err=SOCK:receive(2)
|
||||||
if err then break end
|
if err then break end
|
||||||
|
|
||||||
local op=band(byte(res,1),0x0f)
|
op=band(byte(res,1),0x0f)
|
||||||
local fin=band(byte(res,1),0x80)==0x80
|
fin=band(byte(res,1),0x80)==0x80
|
||||||
|
|
||||||
--Calculating data length
|
--Calculating data length
|
||||||
length=band(byte(res,2),0x7f)
|
length=band(byte(res,2),0x7f)
|
||||||
@@ -171,6 +161,25 @@ while true do--Running
|
|||||||
else
|
else
|
||||||
res=""
|
res=""
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
local s,e,p=SOCK:receive(length)
|
||||||
|
if s then
|
||||||
|
]]..(debug==1 and""or"--")..[[print(("%s<%d>:%s"):format(threadName,length,s))
|
||||||
|
sBuffer=sBuffer..s
|
||||||
|
length=length-#s
|
||||||
|
elseif p then
|
||||||
|
]]..(debug==1 and""or"--")..[[print(("%s<%d>:%s"):format(threadName,length,p))
|
||||||
|
sBuffer=sBuffer..p
|
||||||
|
length=length-#p
|
||||||
|
end
|
||||||
|
if length==0 then
|
||||||
|
res,sBuffer=sBuffer,""
|
||||||
|
UFF=false
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]..(debug==1 and""or"--")..[[print(("%s<[%d]>:%s"):format(threadName,#res,res))
|
||||||
|
|
||||||
--React
|
--React
|
||||||
if op==8 then--8=close
|
if op==8 then--8=close
|
||||||
@@ -203,7 +212,6 @@ while true do--Running
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user