mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 21:17:34 +00:00
rename for load first
This commit is contained in:
parent
ff0a318f80
commit
d275eb7d6b
|
@ -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()
|
Loading…
Reference in New Issue
Block a user