微调ws库,确认连接成功时刷新ping和pong时间

This commit is contained in:
MrZ626
2021-02-22 01:05:05 +08:00
parent 23524e5827
commit 7d90a4dcfc

View File

@@ -178,7 +178,7 @@ end
function WS.close(name)
local ws=wsList[name]
ws.sendCHN:push(8)
ws.sendCHN:push(8)--close
ws.sendCHN:push("")
ws.status="dead"
end
@@ -190,10 +190,12 @@ function WS.update()
if ws.status=="connecting"then
if ws.readCHN:pop()=="success"then
ws.status="running"
ws.lastPingTime=time
ws.lastPongTime=time
end
elseif time-ws.lastPingTime>ws.pingInterval then
ws.sendCHN:push(9)
ws.sendCHN:push("")
ws.sendCHN:push("")--ping
ws.lastPingTime=time
end
if time-ws.lastPongTime>10+3*ws.pingInterval then