local C = Broker_Everything.color
local GetNetStats = GetNetStats
local latency_update_interval = 5


local latency_onupdate = function(self)
	local _, _, l = GetNetStats()
	local _, playerClass = UnitClass("player")
	local suffix = C.class("ms", playerClass)
	local dataobj = self.obj or LibStub:GetLibrary("LibDataBroker-1.1"):GetDataObjectByName(L["LATENCY"])

	if l <= 200 then
		dataobj.text = C.dkgreen(l) .. suffix
	elseif l > 200 and l <= 400 then
		dataobj.text = C.dkyellow(l) .. suffix
	elseif l > 400 then
		dataobj.text = C.red(l) .. suffix
	else
		dataobj.text = l .. suffix
	end
end 


Broker_Everything:Register(L["LATENCY"],
	"Interface\\Addons\\Broker_Everything\\media\\latency", --GetItemIcon(44681),
	0,
	0,
	0,
	0,
	0,
	latency_onupdate,
	latency_update_interval)

