-- @outline // PUBLIC METHODS


function Ping.Get(plr)
	plr = GetPlayer(plr)
	
	local RobloxCalculatedPing = plr:GetNetworkPing()
	return RobloxCalculatedPing ~= 0 and (RobloxCalculatedPing*2) or (Pool[plr] and Pool[plr].Value) or 0
end

function Ping.UpdatePlayer(plr)
	plr = GetPlayer(plr)
	if not Pool[plr] or (Pool[plr].Code ~= -1 and tick() - Pool[plr].Time < MAX_THROTTLE_TIME) then return end
	
	local plrObject = System.Player.Get(plr)
	if not plrObject or not plrObject.Ready then return end
	
	Pool[plr].Code = System.Random:NextInteger(0, 0xFFFF)
	Pool[plr].Time = tick()
	
	System.Remotes.FireClient(plr, "Ping", {Code = Pool[plr].Code, Value = Pool[plr].Value})
end

function Ping.GetAll()
	return Pool
end
