From d5736a5b083796b09cb1b78ac57cf8e86f234435 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 30 May 2021 15:46:29 +0800 Subject: [PATCH] =?UTF-8?q?ws=E6=A8=A1=E5=9D=97=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A=E8=BF=9E=E6=8E=A5=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index d13ca7b4..ab36c69e 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -23,8 +23,9 @@ do--Connect local port=sendCHN:demand() local path=sendCHN:demand() local body=sendCHN:demand() + local timeout=sendCHN:demand() - SOCK:settimeout(2.6) + SOCK:settimeout(timeout) local res,err=SOCK:connect(host,port) if err then readCHN:push(err)return end @@ -232,7 +233,7 @@ local wsList=setmetatable({},{ end }) -function WS.connect(name,subPath,body) +function WS.connect(name,subPath,body,timeout) local ws={ real=true, thread=love.thread.newThread(wsThread), @@ -242,7 +243,7 @@ function WS.connect(name,subPath,body) lastPingTime=0, lastPongTime=timer(), pingInterval=12, - status='connecting',--connecting, running, dead + status='connecting',--'connecting', 'running', 'dead' sendTimer=0, alertTimer=0, pongTimer=0, @@ -253,6 +254,7 @@ function WS.connect(name,subPath,body) ws.sendCHN:push(port) ws.sendCHN:push(path..subPath) ws.sendCHN:push(body or"") + ws.sendCHN:push(timeout or 2.6) end function WS.status(name)