Update k.lua and w.lua #60
@@ -4,9 +4,9 @@ local jua
|
|||||||
local json
|
local json
|
||||||
local await
|
local await
|
||||||
|
|
||||||
local endpoint = "krist.ceriat.net"
|
local endpoint = "krist.dev"
|
||||||
local wsEndpoint = "ws://"..endpoint
|
local wsEndpoint = "wss://"..endpoint
|
||||||
local httpEndpoint = "http://"..endpoint
|
local httpEndpoint = "https://"..endpoint
|
||||||
|
|
||||||
local function asserttype(var, name, vartype, optional)
|
local function asserttype(var, name, vartype, optional)
|
||||||
if not (type(var) == vartype or optional and type(var) == "nil") then
|
if not (type(var) == vartype or optional and type(var) == "nil") then
|
||||||
@@ -53,7 +53,7 @@ local function authorize_websocket(cb, privatekey)
|
|||||||
asserttype(privatekey, "privatekey", "string", true)
|
asserttype(privatekey, "privatekey", "string", true)
|
||||||
|
|
||||||
api_request(function(success, data)
|
api_request(function(success, data)
|
||||||
cb(success and data and data.ok, data.url and data.url:gsub("wss:", "ws:") or data)
|
cb(success and data and data.ok, data.url and data.url:gsub("ws:", "wss:") or data)
|
||||||
end, "/ws/start", {
|
end, "/ws/start", {
|
||||||
privatekey = privatekey
|
privatekey = privatekey
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -79,10 +79,12 @@ function init(jua)
|
|||||||
|
|
||||||
jua.on("websocket_failure", function(event, url)
|
jua.on("websocket_failure", function(event, url)
|
||||||
local id = findID(url)
|
local id = findID(url)
|
||||||
if id and callbackRegistry[id].failure then
|
if id then
|
||||||
callbackRegistry[id].failure(id)
|
if callbackRegistry[id].failure then
|
||||||
|
callbackRegistry[id].failure(id)
|
||||||
|
end
|
||||||
|
table.remove(callbackRegistry, id)
|
||||||
end
|
end
|
||||||
table.remove(callbackRegistry, id)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
jua.on("websocket_message", function(event, url, data)
|
jua.on("websocket_message", function(event, url, data)
|
||||||
@@ -94,10 +96,12 @@ function init(jua)
|
|||||||
|
|
||||||
jua.on("websocket_closed", function(event, url)
|
jua.on("websocket_closed", function(event, url)
|
||||||
local id = findID(url)
|
local id = findID(url)
|
||||||
if id and callbackRegistry[id].closed then
|
if id then
|
||||||
callbackRegistry[id].closed(id)
|
if callbackRegistry[id].closed then
|
||||||
|
callbackRegistry[id].closed(id)
|
||||||
|
end
|
||||||
|
table.remove(callbackRegistry, id)
|
||||||
end
|
end
|
||||||
table.remove(callbackRegistry, id)
|
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
jua.on("socket_connect", function(event, id)
|
jua.on("socket_connect", function(event, id)
|
||||||
@@ -107,10 +111,12 @@ function init(jua)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
jua.on("socket_error", function(event, id, msg)
|
jua.on("socket_error", function(event, id, msg)
|
||||||
if id and callbackRegistry[id].failure then
|
if id then
|
||||||
callbackRegistry[id].failure(id, msg)
|
if callbackRegistry[id].failure then
|
||||||
|
callbackRegistry[id].failure(id)
|
||||||
|
end
|
||||||
|
table.remove(callbackRegistry, id)
|
||||||
end
|
end
|
||||||
table.remove(callbackRegistry, id)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
jua.on("socket_message", function(event, id)
|
jua.on("socket_message", function(event, id)
|
||||||
@@ -121,10 +127,12 @@ function init(jua)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
jua.on("socket_closed", function(event, id)
|
jua.on("socket_closed", function(event, id)
|
||||||
if id and callbackRegistry[id].closed then
|
if id then
|
||||||
callbackRegistry[id].closed(id)
|
if callbackRegistry[id].closed then
|
||||||
|
callbackRegistry[id].closed(id)
|
||||||
|
end
|
||||||
|
table.remove(callbackRegistry, id)
|
||||||
end
|
end
|
||||||
table.remove(callbackRegistry, id)
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user