From 513ca97eb038efea3dd7685a314b3f64e8770784 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 18 Feb 2011 17:05:25 -0800 Subject: [PATCH] Added code to propogate event OnAttach. --- .../SymmetricSync/RegionSyncModule.cs | 45 ++++++++++++++++++- .../SymmetricSync/SymmetricSyncMessage.cs | 1 + .../Region/Framework/Scenes/EventManager.cs | 23 +++++++++- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 5624abba2d..51fed7c2c8 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -692,6 +692,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case EventManager.EventNames.ObjectDeGrab: OnLocalDeGrabObject((uint)evArgs[0], (uint)evArgs[1], (IClientAPI)evArgs[2], (SurfaceTouchEventArgs)evArgs[3]); return; + case EventManager.EventNames.Attach: + OnLocalAttach((uint)evArgs[0], (UUID)evArgs[1], (UUID)evArgs[2]); + return; default: return; } @@ -1431,6 +1434,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ObjectGrab: case SymmetricSyncMessage.MsgType.ObjectGrabbing: case SymmetricSyncMessage.MsgType.ObjectDeGrab: + case SymmetricSyncMessage.MsgType.Attach: { HandleRemoteEvent(msg, senderActorID); return; @@ -1766,6 +1770,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ObjectDeGrab: HandleRemoteEvent_OnObjectDeGrab(init_actorID, evSeqNum, data); break; + case SymmetricSyncMessage.MsgType.Attach: + HandleRemoteEvent_OnAttach(init_actorID, evSeqNum, data); + break; } //if this is a relay node, forwards the event @@ -2018,6 +2025,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.TriggerObjectDeGrabLocally(part.LocalId, originalID, remoteClinet, surfaceArgs); } + private void HandleRemoteEvent_OnAttach(string actorID, ulong evSeqNum, OSDMap data) + { + + UUID primID = data["primID"].AsUUID(); + UUID itemID = data["itemID"].AsUUID(); + UUID avatarID = data["avatarID"].AsUUID(); + + SceneObjectPart part = m_scene.GetSceneObjectPart(primID); + if (part == null) + { + m_log.Warn(LogHeader + ", HandleRemoteEvent_OnAttach: no part with UUID " + primID + " found"); + return; + } + + uint localID = part.LocalId; + m_scene.EventManager.TriggerOnAttachLocally(localID, itemID, avatarID); + + } /// /// The handler for (locally initiated) event OnNewScript: triggered by client's RezSript packet, publish it to other actors. @@ -2127,7 +2152,23 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["type"] = OSD.FromInteger((int)chat.Type); SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data); } - + + private void OnLocalAttach(uint localID, UUID itemID, UUID avatarID) + { + + OSDMap data = new OSDMap(); + SceneObjectPart part = m_scene.GetSceneObjectPart(localID); + if (part == null) + { + m_log.Warn(LogHeader + ", OnLocalAttach: no part with localID: " + localID); + return; + } + data["primID"] = OSD.FromUUID(part.UUID); + data["itemID"] = OSD.FromUUID(itemID); + data["avatarID"] = OSD.FromUUID(avatarID); + SendSceneEvent(SymmetricSyncMessage.MsgType.Attach, data); + } + private void OnLocalGrabObject(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) { /* @@ -2239,6 +2280,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } + + private void SendSceneEvent(SymmetricSyncMessage.MsgType msgType, OSDMap data) { data["actorID"] = OSD.FromString(m_actorID); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs index fe61355f20..522eb2d9a0 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -45,6 +45,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ObjectGrab, ObjectGrabbing, ObjectDeGrab, + Attach, } #endregion diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index d5f5cc93d3..ba02ca258e 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -58,6 +58,7 @@ namespace OpenSim.Region.Framework.Scenes ObjectGrab, ObjectGrabbing, ObjectDeGrab, + Attach, //attaching object to avatar } @@ -238,6 +239,25 @@ namespace OpenSim.Region.Framework.Scenes base.TriggerObjectDeGrab(localID, originalID, remoteClient, surfaceArgs); } + + public override void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localID; + eventArgs[1] = (Object)itemID; + eventArgs[2] = (Object)avatarID; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.Attach, eventArgs); + } + TriggerOnAttachLocally(localID, itemID, avatarID); + } + + public void TriggerOnAttachLocally(uint localID, UUID itemID, UUID avatarID) + { + base.TriggerOnAttach(localID, itemID, avatarID); + } + #endregion //GrabObject } @@ -645,7 +665,8 @@ namespace OpenSim.Region.Framework.Scenes public event LandBuy OnLandBuy; public event LandBuy OnValidateLandBuy; - public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) + //public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) + public virtual void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) { Attach handlerOnAttach = OnAttach; if (handlerOnAttach != null)