ws模块添加发送非字符串信息的检测
This commit is contained in:
@@ -224,6 +224,7 @@ while true do--Running
|
|||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
local type=type
|
||||||
local timer=love.timer.getTime
|
local timer=love.timer.getTime
|
||||||
local CHN=love.thread.newChannel()
|
local CHN=love.thread.newChannel()
|
||||||
local CHN_getCount,CHN_push,CHN_pop=CHN.getCount,CHN.push,CHN.pop
|
local CHN_getCount,CHN_push,CHN_pop=CHN.getCount,CHN.push,CHN.pop
|
||||||
@@ -314,12 +315,17 @@ local OPname={
|
|||||||
[10]='pong',
|
[10]='pong',
|
||||||
}
|
}
|
||||||
function WS.send(name,message,op)
|
function WS.send(name,message,op)
|
||||||
local ws=wsList[name]
|
if type(message)=='string'then
|
||||||
if ws.real and ws.status=='running'then
|
local ws=wsList[name]
|
||||||
CHN_push(ws.sendCHN,op and OPcode[op]or 2)--2=binary
|
if ws.real and ws.status=='running'then
|
||||||
CHN_push(ws.sendCHN,message)
|
CHN_push(ws.sendCHN,op and OPcode[op]or 2)--2=binary
|
||||||
ws.lastPingTime=timer()
|
CHN_push(ws.sendCHN,message)
|
||||||
ws.sendTimer=1
|
ws.lastPingTime=timer()
|
||||||
|
ws.sendTimer=1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
MES.new('error',"Attempt to send non-string value!")
|
||||||
|
MES.traceback()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user