OpenSim.Region.Framework.Scenes.Scene.RemoveClient C# (CSharp) Method

RemoveClient() public method

Remove the given client from the scene.
public RemoveClient ( UUID agentID ) : void
agentID UUID
return void
        public override void RemoveClient(UUID agentID)
        {
            CheckHeartbeat();
            bool childagentYN = false;
            ScenePresence avatar = GetScenePresence(agentID);
            if (avatar != null)
            {
                childagentYN = avatar.IsChildAgent;

                if (avatar.ParentID != 0)
                {
                    avatar.StandUp();
                }

                try
                {
                    m_log.DebugFormat(
                        "[SCENE]: Removing {0} agent {1} from region {2}",
                        (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);

                    m_sceneGraph.removeUserCount(!childagentYN);
                    CapsModule.RemoveCapsHandler(agentID);

                    // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
                    // this method is doing is HORRIBLE!!!
                    avatar.Scene.NeedSceneCacheClear(avatar.UUID);

                    if (!avatar.IsChildAgent)
                    {
                        //List<ulong> childknownRegions = new List<ulong>();
                        //List<ulong> ckn = avatar.KnownChildRegionHandles;
                        //for (int i = 0; i < ckn.Count; i++)
                        //{
                        //    childknownRegions.Add(ckn[i]);
                        //}
                        List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
                        regions.Remove(RegionInfo.RegionHandle);
                        m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);

                    }
                    m_eventManager.TriggerClientClosed(agentID, this);
                }
                catch (NullReferenceException)
                {
                    // We don't know which count to remove it from
                    // Avatar is already disposed :/
                }

                m_eventManager.TriggerOnRemovePresence(agentID);

                ForEachClient(
                    delegate(IClientAPI client)
                    {
                        //We can safely ignore null reference exceptions.  It means the avatar is dead and cleaned up anyway
                        try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }
                        catch (NullReferenceException) { }
                    });

                IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
                if (agentTransactions != null)
                {
                    agentTransactions.RemoveAgentAssetTransactions(agentID);
                }

                // Remove the avatar from the scene
                m_sceneGraph.RemoveScenePresence(agentID);
                m_clientManager.Remove(agentID);

                try
                {
                    avatar.Close();
                }
                catch (NullReferenceException)
                {
                    //We can safely ignore null reference exceptions.  It means the avatar are dead and cleaned up anyway.
                }
                catch (Exception e)
                {
                    m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
                }

                m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
                CleanDroppedAttachments();
                //m_log.InfoFormat("[SCENE] Memory pre  GC {0}", System.GC.GetTotalMemory(false));
                //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
            }
        }

Usage Example

Ejemplo n.º 1
0
        public bool DeleteNPC(UUID agentID, Scene scene)
        {
            lock (m_avatars)
            {
                NPCAvatar av;
                if (m_avatars.TryGetValue(agentID, out av))
                {
//                    m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", agentID, av.Name);
                    scene.RemoveClient(agentID, false);
                    m_avatars.Remove(agentID);

//                    m_log.DebugFormat("[NPC MODULE]: Removed {0} {1}", agentID, av.Name);
                    return true;
                }
            }

//            m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", agentID);
            return false;
        }
All Usage Examples Of OpenSim.Region.Framework.Scenes.Scene::RemoveClient
Scene