mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:07:34 +00:00
fix: better error log
This commit is contained in:
parent
fac8fce32e
commit
ad609e3ae2
|
@ -39,7 +39,9 @@ local socket = GWSockets.createWebSocket(getWebSocketURL())
|
||||||
socket:setHeader("id", gmInte.config.id)
|
socket:setHeader("id", gmInte.config.id)
|
||||||
socket:setHeader("token", gmInte.config.token)
|
socket:setHeader("token", gmInte.config.token)
|
||||||
|
|
||||||
|
local hasConnected = false
|
||||||
function socket:onConnected()
|
function socket:onConnected()
|
||||||
|
hasConnected = true
|
||||||
gmInte.log("WebSocket Connected")
|
gmInte.log("WebSocket Connected")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,18 +58,14 @@ function socket:onMessage(txt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function socket:onDisconnected()
|
function socket:onDisconnected()
|
||||||
gmInte.log("WebSocket Disconnected")
|
if (hasConnected) then
|
||||||
|
gmInte.log("WebSocket Disconnected")
|
||||||
|
else
|
||||||
|
gmInte.logError("WebSocket Connection Failed", true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local lastConnectError = 0
|
|
||||||
function socket:onError(txt)
|
function socket:onError(txt)
|
||||||
if (string.StartWith(txt, "Connection failed:")) then
|
|
||||||
if (CurTime() - lastConnectError < 5) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
gmInte.logError("WebSocket Error: " .. txt, true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
gmInte.logError("WebSocket Error: " .. txt, true)
|
gmInte.logError("WebSocket Error: " .. txt, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user