2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-04-18 20:40:26 +00:00

finished but untest

This commit is contained in:
2022-04-13 22:17:38 +04:00
parent 9f09ed21f1
commit 7de457b6fa
10 changed files with 665 additions and 20 deletions

View File

@@ -0,0 +1,24 @@
local c = redis.call
local curTime = c("TIME")
local time = tonumber(curTime[1])
local heartbeats = c("HGETALL", "heartbeats")
local total = 0
local key
for _, v in ipairs(heartbeats) do
if not key then
key = v
else
local n = tonumber(v)
if n then
if n + 30 >= time then
total = total + c("SCARD", "proxy:" .. key .. ":usersOnline")
end
end
key = nil
end
end
return total

View File

@@ -0,0 +1,18 @@
local call = redis.call
local ipairs = ipairs
local serverToData = {}
for _, proxy in ipairs(ARGV) do
local players = call("SMEMBERS", "proxy:" .. proxy .. ":usersOnline")
for _, player in ipairs(players) do
local server = call("HGET", "player:" .. player, "server")
if server then
local sz = #serverToData
serverToData[sz + 1] = server
serverToData[sz + 2] = player
end
end
end
return serverToData