mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:27: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("token", gmInte.config.token)
|
||||
|
||||
local hasConnected = false
|
||||
function socket:onConnected()
|
||||
hasConnected = true
|
||||
gmInte.log("WebSocket Connected")
|
||||
end
|
||||
|
||||
|
@ -56,18 +58,14 @@ function socket:onMessage(txt)
|
|||
end
|
||||
|
||||
function socket:onDisconnected()
|
||||
gmInte.log("WebSocket Disconnected")
|
||||
if (hasConnected) then
|
||||
gmInte.log("WebSocket Disconnected")
|
||||
else
|
||||
gmInte.logError("WebSocket Connection Failed", true)
|
||||
end
|
||||
end
|
||||
|
||||
local lastConnectError = 0
|
||||
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)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user