spawn(function()for q,f in pairs(topics)do main.messagingService:SubscribeAsync(f,function(q)local P=q.Data if f=="\066\101\103\105\110\080\111\108\108"then local q,f=(main:GetModule("\099\102")):BeginPoll(P)main.messagingService:PublishAsync(P.UniquePollTopic,f)elseif f=="\068\105\115\112\108\097\121\080\111\108\108\082\101\115\117\108\116\115\084\111\083\101\114\118\101\114"then for q,f in pairs(main.players:GetChildren())do(main:GetModule("\099\102")):DisplayPollResults(f,P)end elseif f=="\071\101\116\065\109\111\117\110\116\079\102\083\101\114\118\101\114\115"then local q=P main.messagingService:PublishAsync(q)elseif f=="\071\108\111\098\097\108\065\108\101\114\116"then for q,f in pairs(main.players:GetChildren())do main.signals.CreateAlert:FireClient(f,{P.Title;P.Message})end elseif f=="\071\108\111\098\097\108\067\111\109\109\097\110\100\115"then local f=q.Data if f.Name=="\103\108\111\098\097\108\080\108\097\099\101"then local q=f.PlaceId local P=f.PlaceName for f,C in pairs(main.players:GetChildren())do local m={"\071\108\111\098\097\108 \084\101\108\101\112\111\114\116","\067\108\105\099\107 \116\111 \116\101\108\101\112\111\114\116 \116\111 "..(P..(" \091"..(q.."\093"))),{"\084\101\108\101\112\111\114\116";q}}main.signals.Notice:FireClient(C,m)end end if f.Name=="\103\108\111\098\097\108\070\111\114\099\101\080\108\097\099\101"then local q=f.PlaceId local P=f.PlaceName for f,P in pairs(main.players:GetChildren())do main.teleportService:Teleport(q,P)end end end end)end end)return module
-- << MESSAGING SERVICE >>
spawn(function()
	--testSub:Disconnect()
	for _, topicName in pairs(topics) do
		main.messagingService:SubscribeAsync(topicName, function(message)
			local data = message.Data

			if topicName == "BeginPoll" then
				local newData, scores = main:GetModule("cf"):BeginPoll(data)
				main.messagingService:PublishAsync(data.UniquePollTopic, scores)
			elseif topicName == "DisplayPollResultsToServer" then
				for i, plr in pairs(main.players:GetChildren()) do
					main:GetModule("cf"):DisplayPollResults(plr, data)
				end
			elseif topicName == "GetAmountOfServers" then
				local topicName = data
				main.messagingService:PublishAsync(topicName)
			elseif topicName == "GlobalAlert" then
				for i, plr in pairs(main.players:GetChildren()) do
					main.signals.CreateAlert:FireClient(plr, { data.Title, data.Message })
				end
			elseif topicName == "GlobalCommands" then
				local data = message.Data
				-------------------------------------------
				if data.Name == "globalPlace" then
					local placeId = data.PlaceId
					local placeName = data.PlaceName
					for i, plr in pairs(main.players:GetChildren()) do
						local notice = {
							"Global Teleport",
							"Click to teleport to " .. placeName .. " [" .. placeId .. "]",
							{ "Teleport", placeId },
						}
						main.signals.Notice:FireClient(plr, notice)
					end
				end

				-------------------------------------------
				if data.Name == "globalForcePlace" then
					local placeId = data.PlaceId
					local placeName = data.PlaceName
					for i, plr in pairs(main.players:GetChildren()) do
						main.teleportService:Teleport(placeId, plr)
					end
				end

				-------------------------------------------
			end --]]
		end)
	end
end)

return module
