ForEachScenePresence() public method

Performs action on all scene presences.
public ForEachScenePresence ( Action action ) : void
action Action
return void
        public void OnClosingClient(UUID clientID, Scene scene)
        {
            //Clear out the auth speakers list
            lock (m_authorizedSpeakers)
            {
                if (m_authorizedSpeakers.Contains(clientID))
                    m_authorizedSpeakers.Remove(clientID);
            }

            ScenePresence presence = scene.GetScenePresence(clientID);
            //Announce the closing agent if enabled
            if (m_announceClosedAgents)
            {
                scene.ForEachScenePresence(delegate(ScenePresence SP)
                {
                    if (SP.UUID != clientID && !SP.IsChildAgent)
                    {
                        IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>();
                        if (entityCountModule != null)
                            SP.ControllingClient.SendChatMessage(presence.Name + " has left the region. Total Agents: " + entityCountModule.RootAgents, 1, SP.AbsolutePosition, "System",
                                                           UUID.Zero, (byte)ChatSourceType.System, (byte)ChatAudibleLevel.Fully);
                    }
                }
                );
            }
        }
 private void sendRegionInfoPacketToAll(Scene scene)
 {
     scene.ForEachScenePresence(delegate(ScenePresence sp)
     {
         if (!sp.IsChildAgent)
             HandleRegionInfoRequest(sp.ControllingClient, scene);
     });
 }
示例#3
0
        protected void UpdateBroker(Scene scene)
        {
            if (String.IsNullOrEmpty(m_brokerURI))
                return;

            string uri = String.Format(m_brokerURI, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID);

            // create XML sniplet
            StringBuilder list = new StringBuilder();
            list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n",
                                          scene.GetRootAgentCount(), scene.RegionInfo.RegionName,
                                          scene.RegionInfo.RegionID,
                                          DateTime.UtcNow.ToString("s")));
            scene.ForEachScenePresence(delegate(ScenePresence sp)
            {
                if (!sp.IsChildAgent)
                {
                    list.Append(String.Format("    <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
                    list.Append("</avatars>");
                }
            });
            string payload = list.ToString();

            // post via REST to broker
            HttpWebRequest updatePost = WebRequest.Create(uri) as HttpWebRequest;
            updatePost.Method = "POST";
            updatePost.ContentType = "text/xml";
            updatePost.ContentLength = payload.Length;
            updatePost.UserAgent = "OpenSim.Concierge";


            BrokerState bs = new BrokerState(uri, payload, updatePost);
            bs.Timer = new Timer(delegate(object state)
                                 {
                                     BrokerState b = state as BrokerState;
                                     b.Poster.Abort();
                                     b.Timer.Dispose();
                                     m_log.Debug("[Concierge]: async broker POST abort due to timeout");
                                 }, bs, m_brokerUpdateTimeout * 1000, Timeout.Infinite);

            try
            {
                updatePost.BeginGetRequestStream(UpdateBrokerSend, bs);
                m_log.DebugFormat("[Concierge] async broker POST to {0} started", uri);
            }
            catch (WebException we)
            {
                m_log.ErrorFormat("[Concierge] async broker POST to {0} failed: {1}", uri, we.Status);
            }
        }
        public void OnClosingClient(UUID clientID, Scene scene)
        {
            lock (m_authorizedSpeakers)
            {
                if (m_authorizedSpeakers.Contains(clientID))
                    m_authorizedSpeakers.Remove(clientID);
            }

            int AgentCount = 0;
            lock (RegionAgentCount)
            {
                RegionAgentCount.TryGetValue(scene.RegionInfo.RegionID, out AgentCount);
                AgentCount--;

                if (AgentCount < 0)
                    AgentCount = 0;

                RegionAgentCount[scene.RegionInfo.RegionID] = AgentCount;
            }


            if (m_announceClosedAgents)
            {
                string leavingAvatar = scene.GetUserName(clientID);
                scene.ForEachScenePresence(delegate(ScenePresence SP)
                {
                    if (SP.UUID != clientID && !SP.IsChildAgent)
                    {
                        SP.ControllingClient.SendChatMessage(leavingAvatar + " has left the region. Total Agents: " + AgentCount, 1, SP.AbsolutePosition, "System",
                                                           UUID.Zero, (byte)ChatSourceType.System, (byte)ChatAudibleLevel.Fully);
                    }
                }
                );
            }
        }
        /// <summary>
        /// The Scene is being informed of the new region 'otherRegion'
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="otherRegion"></param>
        public void IncomingHelloNeighbor(Scene scene, GridRegion otherRegion)
        {
            // Let the grid service module know, so this can be cached
            scene.EventManager.TriggerOnRegionUp(otherRegion);

            //Add this new region to all the clients so that they can see it as well
            scene.ForEachScenePresence(delegate(ScenePresence agent)
            {
                // If agent is a root agent.
                if (!agent.IsChildAgent)
                {
                    //Now add the agent to the reigon that is coming up
                    IEntityTransferModule transferModule = scene.RequestModuleInterface<IEntityTransferModule>();
                    if (transferModule != null)
                        transferModule.EnableChildAgents(agent);
                }
            });
        }
        public void OnClosingClient(UUID clientID, Scene scene)
        {
            //Clear out the auth speakers list
            lock (m_authorizedSpeakers)
            {
                if (m_authorizedSpeakers.Contains(clientID))
                    m_authorizedSpeakers.Remove(clientID);
            }

            ScenePresence presence = scene.GetScenePresence(clientID);
            int AgentCount = 0;
            lock (RegionAgentCount)
            {
                RegionAgentCount.TryGetValue(scene.RegionInfo.RegionID, out AgentCount);
                if (!presence.IsChildAgent)
                {
                    //Clean up the agent count
                    AgentCount--;

                    if (AgentCount < 0)
                        AgentCount = 0;

                    RegionAgentCount[scene.RegionInfo.RegionID] = AgentCount;
                }
            }

            //Announce the closing agent if enabled
            if (m_announceClosedAgents)
            {
                UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID,
                    clientID);
                scene.ForEachScenePresence(delegate(ScenePresence SP)
                {
                    if (SP.UUID != clientID && !SP.IsChildAgent)
                    {
                        SP.ControllingClient.SendChatMessage(account.Name + " has left the region. Total Agents: " + AgentCount, 1, SP.AbsolutePosition, "System",
                                                           UUID.Zero, (byte)ChatSourceType.System, (byte)ChatAudibleLevel.Fully);
                    }
                }
                );
            }
        }