OpenSim.Region.CoreModules.Avatar.Gods.GodsModule.KickUser C# (CSharp) Method

KickUser() public method

Kicks User specified from the simulator. This logs them off of the grid If the client gets the UUID: 44e87126e7944ded05b37c42da3d5cdb it assumes that you're kicking it even if the avatar's UUID isn't the UUID that the agent is assigned
public KickUser ( UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte reason ) : void
godID UUID The person doing the kicking
sessionID UUID The session of the person doing the kicking
agentID UUID the person that is being kicked
kickflags uint Tells what to do to the user
reason byte The message to send to the user after it's been turned into a field
return void
        public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
        {
            UUID kickUserID = ALL_AGENTS;
            
            ScenePresence sp = m_scene.GetScenePresence(agentID);

            if (sp != null || agentID == kickUserID)
            {
                if (m_scene.Permissions.IsGod(godID))
                {
                    if (kickflags == 0)
                    {
                        if (agentID == kickUserID)
                        {
                            string reasonStr = Utils.BytesToString(reason);

                            m_scene.ForEachClient(
                                delegate(IClientAPI controller)
                                {
                                    if (controller.AgentId != godID)
                                        controller.Kick(reasonStr);
                                }
                            );

                            // This is a bit crude. It seems the client will be null before it actually stops the thread
                            // The thread will kill itself eventually :/
                            // Is there another way to make sure *all* clients get this 'inter region' message?
                            m_scene.ForEachScenePresence(
                                delegate(ScenePresence p)
                                {
                                    if (p.UUID != godID && !p.IsChildAgent)
                                    {
                                        // Possibly this should really be p.Close() though that method doesn't send a close
                                        // to the client
                                        p.ControllingClient.Close();
                                    }
                                }
                            );
                        }
                        else
                        {
                            m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);

                            sp.ControllingClient.Kick(Utils.BytesToString(reason));
                            sp.ControllingClient.Close();
                        }
                    }
                    
                    if (kickflags == 1)
                    {
                        sp.AllowMovement = false;
                        m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
                        m_dialogModule.SendAlertToUser(godID, "User Frozen");
                    }
                    
                    if (kickflags == 2)
                    {
                        sp.AllowMovement = true;
                        m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
                        m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
                    }
                }
                else
                {
                    m_dialogModule.SendAlertToUser(godID, "Kick request denied");
                }
            }
        }
    }