rename for load first

This commit is contained in:
Linventif 2023-09-27 02:24:24 +02:00
parent ff0a318f80
commit d275eb7d6b

View File

@ -21,6 +21,17 @@ end
// log on message
function socket:onMessage(txt)
gmInte.log("WebSocket Message: " .. txt, true)
local data = util.JSONToTable(txt)
if (gmInte.config.debug) then
gmInte.log("WebSocket Message: " .. txt, true)
end
print(data.method)
print(gmInte[data.method] && "true" || "false")
if (gmInte[data.method]) then
gmInte[data.method](data)
else
gmInte.logError("WebSocket Message: " .. txt .. " is not a valid method !")
end
end
function socket:onDisconnected()
@ -31,10 +42,19 @@ function socket:onError(txt)
gmInte.logError("WebSocket Error: " .. txt)
end
function gmInte.websocketSend(data)
socket:send(util.TableToJSON(data))
function gmInte.websocketWrite(data)
if (!socket:isConnected()) then
socket:open()
end
socket:write(util.TableToJSON(data || {}))
end
timer.Create("gmInte:WebSocket:CheckConnection", 60, 0, function()
if (!socket:isConnected()) then
socket:open()
end
end)
hook.Add("InitPostEntity", "gmInte:ServerReady:WebSocket", function()
timer.Simple(1, function()
socket:open()