Do not run globalstep when no player or no token
This commit is contained in:
parent
5dfcf905f4
commit
1df668e6dc
5
init.lua
5
init.lua
|
@ -172,11 +172,14 @@ end
|
||||||
local INTERVAL = 60
|
local INTERVAL = 60
|
||||||
local HANDLE = nil
|
local HANDLE = nil
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
if MatrixChat.token == nil or #minetest.get_connected_players() == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
if HANDLE == nil then
|
if HANDLE == nil then
|
||||||
local request = MatrixChat:get_sync_table(INTERVAL * 1000)
|
local request = MatrixChat:get_sync_table(INTERVAL * 1000)
|
||||||
request.timeout = INTERVAL
|
request.timeout = INTERVAL
|
||||||
HANDLE = http.fetch_async(request)
|
HANDLE = http.fetch_async(request)
|
||||||
elseif HANDLE ~= nil then
|
else
|
||||||
local result = http.fetch_async_get(HANDLE)
|
local result = http.fetch_async_get(HANDLE)
|
||||||
if result.completed then
|
if result.completed then
|
||||||
if result.code == 200 then
|
if result.code == 200 then
|
||||||
|
|
Loading…
Reference in New Issue