修复ws连接失败时不能正确显示消息
This commit is contained in:
@@ -63,12 +63,16 @@ do--Connect
|
|||||||
--Result
|
--Result
|
||||||
if ctLen then
|
if ctLen then
|
||||||
if code=="101"then
|
if code=="101"then
|
||||||
readCHN:push("success")
|
readCHN:push('success')
|
||||||
else
|
else
|
||||||
res,err=SOCK:receive(ctLen)
|
res,err=SOCK:receive(ctLen)
|
||||||
if not res then readCHN:push(err)return end
|
if not res then
|
||||||
res=JSON.decode(res)
|
readCHN:push(err)
|
||||||
readCHN:push((code or"XXX")..":"..(res and res.reason or"Server Error"))
|
else
|
||||||
|
res=JSON.decode(res)
|
||||||
|
readCHN:push((code or"XXX")..":"..(res and res.reason or"Server Error"))
|
||||||
|
end
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
SOCK:settimeout(0)
|
SOCK:settimeout(0)
|
||||||
@@ -316,8 +320,7 @@ end
|
|||||||
function WS.read(name)
|
function WS.read(name)
|
||||||
local ws=wsList[name]
|
local ws=wsList[name]
|
||||||
if ws.real and ws.readCHN:getCount()>=2 then
|
if ws.real and ws.readCHN:getCount()>=2 then
|
||||||
local op=ws.readCHN:pop()
|
local op,message=ws.readCHN:pop(),ws.readCHN:pop()
|
||||||
local message=ws.readCHN:pop()
|
|
||||||
if op==8 then ws.status='dead'end--8=close
|
if op==8 then ws.status='dead'end--8=close
|
||||||
ws.lastPongTime=timer()
|
ws.lastPongTime=timer()
|
||||||
ws.pongTimer=1
|
ws.pongTimer=1
|
||||||
@@ -342,7 +345,7 @@ function WS.update(dt)
|
|||||||
if ws.status=='connecting'then
|
if ws.status=='connecting'then
|
||||||
local mes=ws.readCHN:pop()
|
local mes=ws.readCHN:pop()
|
||||||
if mes then
|
if mes then
|
||||||
if mes=="success"then
|
if mes=='success'then
|
||||||
ws.status='running'
|
ws.status='running'
|
||||||
ws.lastPingTime=time
|
ws.lastPingTime=time
|
||||||
ws.lastPongTime=time
|
ws.lastPongTime=time
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ return{
|
|||||||
accessFailed="Access Denied.",
|
accessFailed="Access Denied.",
|
||||||
|
|
||||||
wsConnecting="Websocket: Connecting",
|
wsConnecting="Websocket: Connecting",
|
||||||
wsFailed="WebSocket: Connection Failed.",
|
wsFailed="WebSocket: Connection Failed",
|
||||||
wsClose="WebSocket Closed: ",
|
wsClose="WebSocket Closed: ",
|
||||||
netTimeout="Network connection timeout",
|
netTimeout="Network connection timeout",
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user