修复不能正确解析来自服务器的切断ws消息
This commit is contained in:
@@ -188,8 +188,7 @@ while true do--Running
|
|||||||
readCHN:push(op)
|
readCHN:push(op)
|
||||||
SOCK:close()
|
SOCK:close()
|
||||||
if type(res)=='string'then
|
if type(res)=='string'then
|
||||||
res=JSON.decode(res)
|
readCHN:push(res)--Warning: with 2 bytes close code
|
||||||
readCHN:push(res and res.reason or"WS Error")
|
|
||||||
else
|
else
|
||||||
readCHN:push("WS Error")
|
readCHN:push("WS Error")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ end
|
|||||||
|
|
||||||
--WS close message
|
--WS close message
|
||||||
local function wsCloseMessage(message)
|
local function wsCloseMessage(message)
|
||||||
local mes=JSON.decode(message)
|
local mes=JSON.decode(message:sub(3))
|
||||||
if mes then
|
if mes then
|
||||||
LOG.print(("%s [%s] %s"):format(text.wsClose,mes.type or"unknown type",mes.reason or""),'warn')
|
LOG.print(("%s [%s] %s"):format(text.wsClose,mes.type or"unknown type",mes.reason or""),'error')
|
||||||
else
|
else
|
||||||
LOG.print(text.wsClose.."",'warn')
|
LOG.print(text.wsClose,'error')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user