move attachment subscription events into AttachmentsModule from scene.

restored to some heavy casting in order to preserve RegionCombinerModule semantics, pending better events.
prebuild-update
Justin Clark-Casey (justincc) 2010-07-30 21:41:44 +01:00
parent 4d83b2d8a6
commit 424b4b2b86
3 changed files with 28 additions and 38 deletions

View File

@ -56,11 +56,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
m_scene = scene;
m_scene.RegisterModuleInterface<IAttachmentsModule>(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<IAttachmentsModule>(this);
m_scene.EventManager.OnNewClient -= SubscribeToClientEvents;
}
public void RegionLoaded(Scene scene) {}
@ -70,6 +73,24 @@ 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;
}
/// <summary>
/// Called by client
/// </summary>

View File

@ -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
}
/// <summary>
/// Register for events from the client
/// Unsubscribe the client from events.
/// </summary>
/// <param name="client">The IClientAPI of the connected client</param>
/// <param name="client">The IClientAPI of the client</param>
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;

View File

@ -28,6 +28,7 @@
using System;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.RegionCombinerModule
@ -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);