------------------------------------------------------
-- 在线时长上报
------------------------------------------------------

local Util = require("common.Util")
local Msg = require("core.Msg")
local ObjHuman = require("core.ObjHuman")

local REPORT_PER_TIME = 1800

-- 本日在线时间
-- 每1800秒上报1次
function checkReportOnline(human)
	if not human.db then return end

	local nowTime = os.time()
	local time = nowTime - math.max(human.db.lastLoginTime, Util.getDayStartTime(nowTime))
	local oltime = (human.db.onlineTimeDay or 0) + time 
	local oltimecnt = math.floor(oltime / REPORT_PER_TIME)
	local reportTime = oltimecnt * REPORT_PER_TIME
	if reportTime <= (human.db.onlineTimeDayReport or 0) then
		return
	end

	human.db.onlineTimeDayReport = reportTime
	local msgRet = Msg.gc.GC_ONLINETIME_REPORT 
	msgRet.time = reportTime
	--Msg.send(msgRet, human.fd)
end

function onTimer()
	-- for _, human in pairs(ObjHuman.onlineUuid) do
	-- 	checkReportOnline(human)
	-- end
end

function onLogin(human)
	-- checkReportOnline(human)
end