微调ws库,确认连接成功时刷新ping和pong时间
This commit is contained in:
@@ -178,7 +178,7 @@ end
|
|||||||
|
|
||||||
function WS.close(name)
|
function WS.close(name)
|
||||||
local ws=wsList[name]
|
local ws=wsList[name]
|
||||||
ws.sendCHN:push(8)
|
ws.sendCHN:push(8)--close
|
||||||
ws.sendCHN:push("")
|
ws.sendCHN:push("")
|
||||||
ws.status="dead"
|
ws.status="dead"
|
||||||
end
|
end
|
||||||
@@ -190,10 +190,12 @@ function WS.update()
|
|||||||
if ws.status=="connecting"then
|
if ws.status=="connecting"then
|
||||||
if ws.readCHN:pop()=="success"then
|
if ws.readCHN:pop()=="success"then
|
||||||
ws.status="running"
|
ws.status="running"
|
||||||
|
ws.lastPingTime=time
|
||||||
|
ws.lastPongTime=time
|
||||||
end
|
end
|
||||||
elseif time-ws.lastPingTime>ws.pingInterval then
|
elseif time-ws.lastPingTime>ws.pingInterval then
|
||||||
ws.sendCHN:push(9)
|
ws.sendCHN:push(9)
|
||||||
ws.sendCHN:push("")
|
ws.sendCHN:push("")--ping
|
||||||
ws.lastPingTime=time
|
ws.lastPingTime=time
|
||||||
end
|
end
|
||||||
if time-ws.lastPongTime>10+3*ws.pingInterval then
|
if time-ws.lastPongTime>10+3*ws.pingInterval then
|
||||||
|
|||||||
Reference in New Issue
Block a user