整理代码,修复一些小错误
This commit is contained in:
@@ -84,10 +84,8 @@ do--Connect
|
|||||||
ctLen=tonumber(l:match"%d+")
|
ctLen=tonumber(l:match"%d+")
|
||||||
end
|
end
|
||||||
until l==""
|
until l==""
|
||||||
l=SOCK:receive(ctLen)
|
local reason=JSON.decode(SOCK:receive(ctLen))
|
||||||
local reason=JSON.decode(l)
|
readCHN:push(code..":"..(reason and reason.message or"Server Error"))
|
||||||
if reason then reason=reason.message end
|
|
||||||
readCHN:push(code.."-"..(reason or l))
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
readCHN:push(err)
|
readCHN:push(err)
|
||||||
@@ -97,7 +95,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
while true do
|
while true do--Running
|
||||||
triggerCHN:demand()
|
triggerCHN:demand()
|
||||||
while sendCHN:getCount()>=2 do
|
while sendCHN:getCount()>=2 do
|
||||||
local op=sendCHN:pop()
|
local op=sendCHN:pop()
|
||||||
@@ -137,7 +135,7 @@ while true do
|
|||||||
reason=JSON.decode(res)if reason then reason=reason.message end
|
reason=JSON.decode(res)if reason then reason=reason.message end
|
||||||
readCHN:push(code.."-"..(reason or res))
|
readCHN:push(code.."-"..(reason or res))
|
||||||
else
|
else
|
||||||
readCHN:push(string.format("%d-%s",shl(byte(res,1),8)+byte(res,2).."-"..res:sub(3,-3)))
|
readCHN:push(string.format("%d-%s",shl(byte(res,1),8)+byte(res,2),res:sub(3,-3)))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
readCHN:push(res)
|
readCHN:push(res)
|
||||||
@@ -196,8 +194,8 @@ end
|
|||||||
function WS.read(name)
|
function WS.read(name)
|
||||||
local ws=wsList[name]
|
local ws=wsList[name]
|
||||||
if ws.readCHN:getCount()>=2 then
|
if ws.readCHN:getCount()>=2 then
|
||||||
local op=ws.readCHN.pop()
|
local op=ws.readCHN:pop()
|
||||||
local message=ws.readCHN.pop()
|
local message=ws.readCHN:pop()
|
||||||
if op==8 then ws.status="dead"end
|
if op==8 then ws.status="dead"end
|
||||||
ws.lastPongTime=timer()
|
ws.lastPongTime=timer()
|
||||||
return message,op
|
return message,op
|
||||||
|
|||||||
Reference in New Issue
Block a user