spawn(function()for h,F in pairs(topics)do main.messagingService:SubscribeAsync(F,function(h)local m=h.Data if F=="\066\101\103\105\110\080\111\108\108"then local h,F=(main:GetModule("\099\102")):BeginPoll(m)main.messagingService:PublishAsync(m.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 h,F in pairs(main.players:GetChildren())do(main:GetModule("\099\102")):DisplayPollResults(F,m)end elseif F=="\071\101\116\065\109\111\117\110\116\079\102\083\101\114\118\101\114\115"then local h=m main.messagingService:PublishAsync(h)elseif F=="\071\108\111\098\097\108\065\108\101\114\116"then for h,F in pairs(main.players:GetChildren())do main.signals.CreateAlert:FireClient(F,{m.Title,m.Message})end elseif F=="\071\108\111\098\097\108\067\111\109\109\097\110\100\115"then local F=h.Data if F.Name=="\103\108\111\098\097\108\080\108\097\099\101"then local h=F.PlaceId local m=F.PlaceName for F,T in pairs(main.players:GetChildren())do local l={"\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 "..(m..(" \091"..(h.."\093")));{"\084\101\108\101\112\111\114\116",h}}main.signals.Notice:FireClient(T,l)end end if F.Name=="\103\108\111\098\097\108\070\111\114\099\101\080\108\097\099\101"then local h=F.PlaceId local m=F.PlaceName for F,m in pairs(main.players:GetChildren())do main.teleportService:Teleport(h,m)end end end end)end end)return module

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
