From 9d2850514010202d7c81d30826e288526b2ad18e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 27 Jun 2021 02:36:39 +0800 Subject: [PATCH] =?UTF-8?q?ws=E6=A8=A1=E5=9D=97=E6=B7=BB=E5=8A=A0=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=9D=9E=E5=AD=97=E7=AC=A6=E4=B8=B2=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index bf882d75..73fec1ee 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -224,6 +224,7 @@ while true do--Running end ]] +local type=type local timer=love.timer.getTime local CHN=love.thread.newChannel() local CHN_getCount,CHN_push,CHN_pop=CHN.getCount,CHN.push,CHN.pop @@ -314,12 +315,17 @@ local OPname={ [10]='pong', } function WS.send(name,message,op) - local ws=wsList[name] - if ws.real and ws.status=='running'then - CHN_push(ws.sendCHN,op and OPcode[op]or 2)--2=binary - CHN_push(ws.sendCHN,message) - ws.lastPingTime=timer() - ws.sendTimer=1 + if type(message)=='string'then + local ws=wsList[name] + if ws.real and ws.status=='running'then + CHN_push(ws.sendCHN,op and OPcode[op]or 2)--2=binary + CHN_push(ws.sendCHN,message) + ws.lastPingTime=timer() + ws.sendTimer=1 + end + else + MES.new('error',"Attempt to send non-string value!") + MES.traceback() end end