Merge pull request #12 from Kan18/develop-1.8

Fix swshop breaking with other websockets
This commit was merged in pull request #12.
This commit is contained in:
kepler155c
2019-07-18 17:16:15 -06:00
committed by GitHub

View File

@@ -71,14 +71,14 @@ function init(jua)
jua = jua jua = jua
if async then if async then
jua.on("websocket_success", function(event, url, handle) jua.on("websocket_success", function(event, url, handle)
local id = findID(url) local success, id = pcall(findID,url)
if id and callbackRegistry[id] and callbackRegistry[id].success then if id and callbackRegistry[id] and callbackRegistry[id].success then
callbackRegistry[id].success(id, handle) callbackRegistry[id].success(id, handle)
end end
end) end)
jua.on("websocket_failure", function(event, url) jua.on("websocket_failure", function(event, url)
local id = findID(url) local success, id = pcall(findID,url)
if id and callbackRegistry[id] and callbackRegistry[id].failure then if id and callbackRegistry[id] and callbackRegistry[id].failure then
callbackRegistry[id].failure(id) callbackRegistry[id].failure(id)
end end
@@ -86,14 +86,14 @@ function init(jua)
end) end)
jua.on("websocket_message", function(event, url, data) jua.on("websocket_message", function(event, url, data)
local id = findID(url) local success, id = pcall(findID,url)
if id and callbackRegistry[id] and callbackRegistry[id].message then if id and callbackRegistry[id] and callbackRegistry[id].message then
callbackRegistry[id].message(id, data) callbackRegistry[id].message(id, data)
end end
end) end)
jua.on("websocket_closed", function(event, url) jua.on("websocket_closed", function(event, url)
local id = findID(url) local success, id = pcall(findID,url)
if id and callbackRegistry[id] and callbackRegistry[id].closed then if id and callbackRegistry[id] and callbackRegistry[id].closed then
callbackRegistry[id].closed(id) callbackRegistry[id].closed(id)
end end