From 424b4b2b8663f0f6780d2d3a2656e5b298418711 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 30 Jul 2010 21:41:44 +0100 Subject: move attachment subscription events into AttachmentsModule from scene. restored to some heavy casting in order to preserve RegionCombinerModule semantics, pending better events. --- .../Avatar/Attachments/AttachmentsModule.cs | 23 +++++++++++++- OpenSim/Region/Framework/Scenes/Scene.cs | 36 ++-------------------- .../RegionCombinerIndividualEventForwarder.cs | 7 +++-- 3 files changed, 28 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 1187e91..d895bb1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -56,11 +56,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { m_scene = scene; m_scene.RegisterModuleInterface(this); + m_scene.EventManager.OnNewClient += SubscribeToClientEvents; + // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI } public void RemoveRegion(Scene scene) { m_scene.UnregisterModuleInterface(this); + m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; } public void RegionLoaded(Scene scene) {} @@ -69,7 +72,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { RemoveRegion(m_scene); } - + + public void SubscribeToClientEvents(IClientAPI client) + { + client.OnRezSingleAttachmentFromInv += RezSingleAttachmentFromInventory; + client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; + client.OnObjectAttach += AttachObject; + client.OnObjectDetach += DetachObject; + client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory; + } + + public void UnsubscribeFromClientEvents(IClientAPI client) + { + client.OnRezSingleAttachmentFromInv -= RezSingleAttachmentFromInventory; + client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; + client.OnObjectAttach -= AttachObject; + client.OnObjectDetach -= DetachObject; + client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory; + } + /// /// Called by client /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9141d44..088d210 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2783,17 +2783,12 @@ namespace OpenSim.Region.Framework.Scenes SubscribeToClientPrimEvents(client); SubscribeToClientPrimRezEvents(client); SubscribeToClientInventoryEvents(client); - SubscribeToClientAttachmentEvents(client); SubscribeToClientTeleportEvents(client); SubscribeToClientScriptEvents(client); SubscribeToClientParcelEvents(client); SubscribeToClientGridEvents(client); SubscribeToClientGodEvents(client); - SubscribeToClientNetworkEvents(client); - - - // EventManager.TriggerOnNewClient(client); } public virtual void SubscribeToClientTerrainEvents(IClientAPI client) @@ -2874,18 +2869,6 @@ namespace OpenSim.Region.Framework.Scenes client.OnMoveTaskItem += ClientMoveTaskInventoryItem; } - public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) - { - if (AttachmentsModule != null) - { - client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; - client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory; - client.OnObjectAttach += AttachmentsModule.AttachObject; - client.OnObjectDetach += AttachmentsModule.DetachObject; - client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; - } - } - public virtual void SubscribeToClientTeleportEvents(IClientAPI client) { client.OnTeleportLocationRequest += RequestTeleportLocation; @@ -2934,16 +2917,15 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Register for events from the client + /// Unsubscribe the client from events. /// - /// The IClientAPI of the connected client + /// The IClientAPI of the client public virtual void UnSubscribeToClientEvents(IClientAPI client) { UnSubscribeToClientTerrainEvents(client); UnSubscribeToClientPrimEvents(client); UnSubscribeToClientPrimRezEvents(client); UnSubscribeToClientInventoryEvents(client); - UnSubscribeToClientAttachmentEvents(client); UnSubscribeToClientTeleportEvents(client); UnSubscribeToClientScriptEvents(client); UnSubscribeToClientParcelEvents(client); @@ -2951,8 +2933,6 @@ namespace OpenSim.Region.Framework.Scenes UnSubscribeToClientGodEvents(client); UnSubscribeToClientNetworkEvents(client); - - // EventManager.TriggerOnNewClient(client); } public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) @@ -3029,18 +3009,6 @@ namespace OpenSim.Region.Framework.Scenes client.OnMoveTaskItem -= ClientMoveTaskInventoryItem; } - public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) - { - if (AttachmentsModule != null) - { - client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; - client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory; - client.OnObjectAttach -= AttachmentsModule.AttachObject; - client.OnObjectDetach -= AttachmentsModule.DetachObject; - client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; - } - } - public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) { client.OnTeleportLocationRequest -= RequestTeleportLocation; diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs index 9d41c9c..62410e2 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs @@ -28,11 +28,12 @@ using System; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Region.CoreModules.Avatar.Attachments; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.RegionCombinerModule { - public class RegionCombinerIndividualEventForwarder + public class RegionCombinerIndividualEventForwarder { private Scene m_rootScene; private Scene m_virtScene; @@ -48,7 +49,7 @@ namespace OpenSim.Region.RegionCombinerModule m_virtScene.UnSubscribeToClientPrimEvents(client); m_virtScene.UnSubscribeToClientPrimRezEvents(client); m_virtScene.UnSubscribeToClientInventoryEvents(client); - m_virtScene.UnSubscribeToClientAttachmentEvents(client); + ((AttachmentsModule)m_virtScene.AttachmentsModule).UnsubscribeFromClientEvents(client); //m_virtScene.UnSubscribeToClientTeleportEvents(client); m_virtScene.UnSubscribeToClientScriptEvents(client); m_virtScene.UnSubscribeToClientGodEvents(client); @@ -58,7 +59,7 @@ namespace OpenSim.Region.RegionCombinerModule client.OnAddPrim += LocalAddNewPrim; client.OnRezObject += LocalRezObject; m_rootScene.SubscribeToClientInventoryEvents(client); - m_rootScene.SubscribeToClientAttachmentEvents(client); + ((AttachmentsModule)m_rootScene.AttachmentsModule).SubscribeToClientEvents(client); //m_rootScene.SubscribeToClientTeleportEvents(client); m_rootScene.SubscribeToClientScriptEvents(client); m_rootScene.SubscribeToClientGodEvents(client); -- cgit v1.1