From 944b118c622159c87e7f89c05892458d88797d58 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 24 Nov 2007 03:28:42 +0000 Subject: * Added a way for the Region master user to kick individual users from their sim with a custom message. Their client says, "You've been logged off of secondlife, and logs them off. * Added a way for the Region master user to kick *ALL* users from *ALL* their regions in the estate with a custom message. --- OpenSim/Region/Environment/Scenes/Scene.cs | 69 +++++++++++++++++++++- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 13 ---- 2 files changed, 66 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 234b12a..0883e5c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -257,9 +257,15 @@ namespace OpenSim.Region.Environment.Scenes { ForEachScenePresence(delegate(ScenePresence avatar) { - avatar.Kick("The region is going down."); - avatar.ControllingClient.Stop(); + avatar.ControllingClient.Kick("The region is going down."); + }); + ForEachScenePresence(delegate(ScenePresence avatar) + { + avatar.ControllingClient.Stop(); + + }); + m_heartbeatTimer.Close(); m_innerScene.Close(); @@ -831,6 +837,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); client.OnRequestGodlikePowers += handleRequestGodlikePowers; + client.OnGodKickUser += handleGodlikeKickUser; client.OnCreateNewInventoryItem += CreateNewInventoryItem; client.OnCreateNewInventoryFolder += CommsManager.UserProfileCache.HandleCreateInventoryFolder; @@ -883,8 +890,19 @@ namespace OpenSim.Region.Environment.Scenes m_eventManager.TriggerOnRemovePresence(agentID); ScenePresence avatar = GetScenePresence(agentID); + + Broadcast(delegate(IClientAPI client) { + try + { + client.SendKillObject(avatar.RegionHandle, avatar.LocalId); + } + catch (NullReferenceException NE) + { + //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. + + } + }); - Broadcast(delegate(IClientAPI client) { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }); ForEachScenePresence( delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); @@ -1209,6 +1227,51 @@ namespace OpenSim.Region.Environment.Scenes } + public void handleGodlikeKickUser(LLUUID godid, LLUUID sessionid, LLUUID agentid, uint kickflags, byte[] reason) + { + // For some reason the client sends the seemingly hard coded, 44e87126e7944ded05b37c42da3d5cdb + // for kicking everyone. Dun-know. + if (m_scenePresences.ContainsKey(agentid) || agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb")) + { + if (godid == RegionInfo.MasterAvatarAssignedUUID) + { + if (agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb")) + { + + ClientManager.ForEachClient(delegate (IClientAPI controller) + { + if (controller.AgentId != godid) // Do we really want to kick the initiator of this madness? + { + controller.Kick(Helpers.FieldToUTF8String(reason)); + } + } + ); + // 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? + ClientManager.ForEachClient(delegate (IClientAPI controller) + { + if (controller.AgentId != godid) // Do we really want to kick the initiator of this madness? + { + controller.Close(); + } + } + ); + } + else + { + m_scenePresences[agentid].ControllingClient.Kick(Helpers.FieldToUTF8String(reason)); + m_scenePresences[agentid].ControllingClient.Close(); + } + } + else + { + if (m_scenePresences.ContainsKey(godid)) + m_scenePresences[godid].ControllingClient.SendAgentAlertMessage("Kick request denied", false); + } + } + } + public void SendAlertToUser(string firstName, string lastName, string message, bool modal) { foreach (ScenePresence presence in m_scenePresences.Values) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index f91913d..6117828 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1219,20 +1219,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion - public void Kick(string message) - { - KickUserPacket kupack = new KickUserPacket(); - KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; - - kupack.UserInfo.AgentID = UUID; - kupack.UserInfo.SessionID = this.ControllingClient.SessionId; - kupack.TargetBlock.TargetIP = (uint)0; - kupack.TargetBlock.TargetPort = (ushort)0; - kupack.UserInfo.Reason = Helpers.StringToField(message); - ControllingClient.OutPacket(kupack, ThrottleOutPacketType.Task); - - } public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token) { GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); -- cgit v1.1