⚠️ IMPORTANT LOCALHOST LIMITATION:
localhost only works from the same computer running this server. Other Infinity Hub users cannot access http://localhost:3000 from their computers. For live announcements to users outside your network, deploy this server publicly (VPS, Railway, Render, etc.) and update PUBLIC_BASE_URL in .env.
-- =========================================================
-- Infinity Hub Announcement Poller
-- =========================================================
local HttpService = game:GetService("HttpService")
local InfinityConfig = {
ApiUrl = "http://localhost:3000/api/announcements/latest",
PollInterval = 15,
HubVersion = "2.1.0",
CurrentModule = "Ride A Pet",
DebugMode = true
}
local lastSeenAnnouncementId = nil
-- Non-blocking announcement fetcher
local function FetchLatestAnnouncement()
local ok, raw = pcall(function()
return game:HttpGet(InfinityConfig.ApiUrl .. "?t=" .. tostring(tick()))
end)
if not ok or not raw or raw == "" or raw == "null" then return nil end
local decodeOk, data = pcall(function()
return HttpService:JSONDecode(raw)
end)
return (decodeOk and type(data) == "table") and data or nil
end
-- Start background polling loop
task.spawn(function()
while task.wait(InfinityConfig.PollInterval) do
local announcement = FetchLatestAnnouncement()
if announcement and announcement.active and announcement.id ~= lastSeenAnnouncementId then
lastSeenAnnouncementId = announcement.id
if InfinityConfig.DebugMode then
print("[Infinity Hub] New Announcement: " .. tostring(announcement.title))
end
-- Trigger popup in GUI:
-- ShowAnnouncementNotification(announcement)
end
end
end)