fix: better error log

This commit is contained in:
Linventif 2024-03-29 15:04:23 +01:00
parent fac8fce32e
commit ad609e3ae2
No known key found for this signature in database
GPG Key ID: FAC0CA60F9AEEC24

View File

@ -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()
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