Added chat command to debug syncing
This commit is contained in:
parent
45292083f2
commit
0a910c3aec
39
init.lua
39
init.lua
@ -50,17 +50,17 @@ local function mchat(data)
|
||||
end
|
||||
end
|
||||
|
||||
local function msync()
|
||||
local function msync(s)
|
||||
-- optimization note: request more recent instead of unfiltered req
|
||||
-- local param1 = '&filter={\"room\":{\"timeline\":{\"limit\":1}}}'
|
||||
local param1 = "?access_token=" .. token
|
||||
local param2 = "&full_state=false"
|
||||
local param3 = "&timeout=30000"
|
||||
local param3 = "&timeout=5000"
|
||||
local u = MATRIX_SERVER.."/_matrix/client/r0/sync" .. param1 .. param2 .. param3
|
||||
if since == nil then -- first time sync
|
||||
if s == nil then -- first time sync
|
||||
-- do nothing for now
|
||||
else -- second time sync -> append since parameter
|
||||
u = u .. "&since="..since
|
||||
u = u .. "&since="..s
|
||||
end
|
||||
http.fetch({url=u},
|
||||
function (res)
|
||||
@ -92,8 +92,8 @@ local function mlogin()
|
||||
minetest.log("action", res.data)
|
||||
local data = minetest.parse_json(res.data)
|
||||
token = data.access_token
|
||||
minetest.log("action", "Matrix authenticated")
|
||||
msync()
|
||||
minetest.log("action", "Matrix authenticated")
|
||||
else
|
||||
minetest.log("error", to_string(res))
|
||||
end
|
||||
@ -129,14 +129,27 @@ end
|
||||
-- end
|
||||
-- end)
|
||||
|
||||
local GLOBAL_STEPS = 0
|
||||
minetest.register_globalstep(function(dtine)
|
||||
-- print(GLOBAL_STEPS)
|
||||
if GLOBAL_STEPS == 4 then
|
||||
msync()
|
||||
end
|
||||
GLOBAL_STEPS = (GLOBAL_STEPS + 1) % 5
|
||||
end)
|
||||
-- local GLOBAL_STEPS = 0
|
||||
-- minetest.register_globalstep(function(dtine)
|
||||
-- -- print(GLOBAL_STEPS)
|
||||
-- if GLOBAL_STEPS == 4 then
|
||||
-- msync()
|
||||
-- end
|
||||
-- GLOBAL_STEPS = (GLOBAL_STEPS + 1) % 5
|
||||
-- end)
|
||||
|
||||
minetest.register_chatcommand("msync", {
|
||||
privs = {
|
||||
interact = true
|
||||
},
|
||||
func = function(name, param)
|
||||
if param == "nil" then
|
||||
msync()
|
||||
else
|
||||
msync(since)
|
||||
end
|
||||
return true, "[matrix_bridge] Fetching from matrix..."
|
||||
end})
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
|
Loading…
x
Reference in New Issue
Block a user