mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-16 05:57:35 +00:00
rename for load first
This commit is contained in:
parent
ff0a318f80
commit
d275eb7d6b
|
@ -21,6 +21,17 @@ end
|
||||||
// log on message
|
// log on message
|
||||||
function socket:onMessage(txt)
|
function socket:onMessage(txt)
|
||||||
gmInte.log("WebSocket Message: " .. txt, true)
|
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
|
end
|
||||||
|
|
||||||
function socket:onDisconnected()
|
function socket:onDisconnected()
|
||||||
|
@ -31,9 +42,18 @@ function socket:onError(txt)
|
||||||
gmInte.logError("WebSocket Error: " .. txt)
|
gmInte.logError("WebSocket Error: " .. txt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.websocketSend(data)
|
function gmInte.websocketWrite(data)
|
||||||
socket:send(util.TableToJSON(data))
|
if (!socket:isConnected()) then
|
||||||
|
socket:open()
|
||||||
end
|
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()
|
hook.Add("InitPostEntity", "gmInte:ServerReady:WebSocket", function()
|
||||||
timer.Simple(1, function()
|
timer.Simple(1, function()
|
Loading…
Reference in New Issue
Block a user