Abandoned the previous temporary solution of propogating events. Instead, rename legacy (Scene)EventManager
as EventManagerBase, and implement a new EventManager, to enable handling local/remote events differently. Handlers for UpdateScript has been implemented as a sample case.dsg
parent
9b34d50643
commit
837a77b24a
|
@ -87,12 +87,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
||||
InstallInterfaces();
|
||||
|
||||
//Register for Scene events
|
||||
//Register for local Scene events
|
||||
m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
|
||||
m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene);
|
||||
|
||||
//Register for scene events that need to be propogated to other actors
|
||||
m_scene.EventManager.OnUpdateScript += RegionSyncModule_OnUpdateScript;
|
||||
}
|
||||
|
||||
//Called after AddRegion() has been called for all region modules of the scene
|
||||
|
@ -842,9 +840,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
return;
|
||||
}
|
||||
//EVENTS PROCESSING
|
||||
case SymmetricSyncMessage.MsgType.OnUpdateScript:
|
||||
case SymmetricSyncMessage.MsgType.UpdateScript:
|
||||
{
|
||||
HandleEvent_OnUpdateScript(msg);
|
||||
HandleRemoteEvent_OnUpdateScript(msg);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
|
@ -980,7 +978,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
/// Handler for SymmetricSyncMessage.MsgType.OnUpdateScript
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
private void HandleEvent_OnUpdateScript(SymmetricSyncMessage msg)
|
||||
private void HandleRemoteEvent_OnUpdateScript(SymmetricSyncMessage msg)
|
||||
{
|
||||
m_log.Debug(LogHeader + ", " + m_actorID + ": received OnUpdateScript");
|
||||
|
||||
|
@ -993,10 +991,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
UUID primID = data["primID"].AsUUID();
|
||||
bool isRunning = data["running"].AsBoolean();
|
||||
UUID assetID = data["assetID"].AsUUID();
|
||||
//m_scene.EventManager.TriggerUpdateScript(agentID, itemID, primID, isRunning, assetID);
|
||||
m_scene.EventManager.TriggerUpdateScriptLocally(agentID, itemID, primID, isRunning, assetID);
|
||||
|
||||
//trigger the OnUpdateScriptBySync event, so that the handler of the event knows it is event initiated remotely
|
||||
m_scene.EventManager.TriggerOnUpdateScriptBySync(agentID, itemID, primID, isRunning, assetID);
|
||||
//m_scene.EventManager.TriggerOnUpdateScriptBySync(agentID, itemID, primID, isRunning, assetID);
|
||||
|
||||
|
||||
//if this is a relay node, forwards the event
|
||||
|
@ -1031,6 +1029,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
|
||||
}
|
||||
|
||||
public void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs)
|
||||
{
|
||||
switch (ev)
|
||||
{
|
||||
case EventManager.EventNames.UpdateScript:
|
||||
if (evArgs.Length < 5)
|
||||
{
|
||||
m_log.Error(LogHeader + " not enough event args for UpdateScript");
|
||||
return;
|
||||
}
|
||||
m_log.Debug(LogHeader + " PublishSceneEvent UpdateScript");
|
||||
OnLocalUpdateScript((UUID)evArgs[0], (UUID)evArgs[1], (UUID)evArgs[2], (bool)evArgs[3], (UUID)evArgs[4]);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The handler for (locally initiated) event OnUpdateScript: publish it to other actors.
|
||||
/// </summary>
|
||||
|
@ -1039,7 +1055,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
/// <param name="primId"></param>
|
||||
/// <param name="isScriptRunning"></param>
|
||||
/// <param name="newAssetID"></param>
|
||||
public void RegionSyncModule_OnUpdateScript(UUID agentID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
|
||||
private void OnLocalUpdateScript(UUID agentID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
|
||||
{
|
||||
m_log.Debug(LogHeader + " RegionSyncModule_OnUpdateScript");
|
||||
|
||||
|
@ -1050,9 +1066,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
data["running"] = OSD.FromBoolean(isScriptRunning);
|
||||
data["assetID"] = OSD.FromUUID(newAssetID);
|
||||
|
||||
PublishSceneEvent(data);
|
||||
data["actorID"] = OSD.FromString(m_actorID);
|
||||
data["seqNum"] = OSD.FromULong(GetNextEventSeq());
|
||||
|
||||
SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdateScript, OSDParser.SerializeJsonString(data));
|
||||
//send to actors who are interested in the event
|
||||
SendSceneEventToRelevantSyncConnectors(m_actorID, rsm);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
private void PublishSceneEvent(OSDMap data)
|
||||
{
|
||||
data["actorID"] = OSD.FromString(m_actorID);
|
||||
|
@ -1061,6 +1084,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.OnUpdateScript, OSDParser.SerializeJsonString(data));
|
||||
SendSceneEventToRelevantSyncConnectors(m_actorID, rsm);
|
||||
}
|
||||
* */
|
||||
|
||||
private ulong GetNextEventSeq()
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
//for local OnUpdateScript, we'll handle it the same way as a remove OnUpdateScript.
|
||||
//RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors.
|
||||
m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript;
|
||||
m_scene.EventManager.OnUpdateScriptBySync += ScriptEngine_OnUpdateScript;
|
||||
//m_scene.EventManager.OnUpdateScriptBySync += ScriptEngine_OnUpdateScript;
|
||||
}
|
||||
|
||||
//Called after AddRegion() has been called for all region modules of the scene.
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
//RegionStatus,
|
||||
ActorID,
|
||||
//events
|
||||
OnUpdateScript,
|
||||
UpdateScript,
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
//KittyL: Added to support running script engine actor
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using OpenMetaverse;
|
||||
|
@ -65,6 +65,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
void SendTerrainUpdates(string lastUpdateActorID);
|
||||
//void SendDeleteObject(SceneObjectGroup sog);
|
||||
|
||||
//For propogating scene events to other actors
|
||||
void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs);
|
||||
|
||||
//TODO LIST:
|
||||
//Special API for handling avatars
|
||||
//void QueuePresenceForTerseUpdate(ScenePresence presence)
|
||||
|
|
|
@ -41,9 +41,50 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
//SYMMETRIC SYNC: Rename the original EventManager as EventManagerBase, and implement a new EventManager that inherits from EventManagerBase
|
||||
|
||||
/// <summary>
|
||||
/// A class for triggering remote scene events.
|
||||
/// A wrapper class to implement handle event differently depending on if they are initiated locally or remotelly (i.e. by another actor)
|
||||
/// </summary>
|
||||
public class EventManager
|
||||
public class EventManager: EventManagerBase
|
||||
{
|
||||
private Scene m_scene;
|
||||
|
||||
//the events that we'll handle specially in sym-sync
|
||||
public enum EventNames
|
||||
{
|
||||
UpdateScript,
|
||||
}
|
||||
|
||||
public EventManager(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
public override void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
|
||||
{
|
||||
//publish the event to other actors who are intersted in it
|
||||
if (m_scene.RegionSyncModule != null)
|
||||
{
|
||||
Object[] eventArgs = new Object[5];
|
||||
eventArgs[0] = (Object) clientId;
|
||||
eventArgs[1] = (Object)itemId;
|
||||
eventArgs[2] = (Object)primId;
|
||||
eventArgs[3] = (Object)isScriptRunning;
|
||||
eventArgs[4] = (Object)newAssetID;
|
||||
m_scene.RegionSyncModule.PublishSceneEvent(EventNames.UpdateScript, eventArgs);
|
||||
}
|
||||
|
||||
//trigger event locally, as the legacy code does
|
||||
TriggerUpdateScriptLocally(clientId, itemId, primId, isScriptRunning, newAssetID);
|
||||
}
|
||||
|
||||
public void TriggerUpdateScriptLocally(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
|
||||
{
|
||||
base.TriggerUpdateScript(clientId, itemId, primId, isScriptRunning, newAssetID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A class for triggering scene events.
|
||||
/// </summary>
|
||||
public class EventManagerBase
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -2195,7 +2236,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
//OnUpdateTaskInventoryScriptAsset: triggered after Scene receives client's upload of updated script and stores it as asset
|
||||
public delegate void UpdateScript(UUID clientID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID);
|
||||
public event UpdateScript OnUpdateScript;
|
||||
public void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
|
||||
public virtual void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
|
||||
{
|
||||
UpdateScript handlerUpdateScript = OnUpdateScript;
|
||||
if (handlerUpdateScript != null)
|
||||
|
@ -2292,28 +2333,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public event UpdateScriptBySync OnUpdateScriptBySync;
|
||||
public delegate void UpdateScriptBySync(UUID agentID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID);
|
||||
public void TriggerOnUpdateScriptBySync(UUID agentID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID)
|
||||
{
|
||||
UpdateScriptBySync handlerUpdateScriptBySync = OnUpdateScriptBySync;
|
||||
if (handlerUpdateScriptBySync != null)
|
||||
{
|
||||
foreach (UpdateScriptBySync d in handlerUpdateScriptBySync.GetInvocationList())
|
||||
{
|
||||
try
|
||||
{
|
||||
d(agentID, itemId, primId, isScriptRunning, newAssetID);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[EVENT MANAGER]: Delegate for TriggerOnUpdateScriptBySync failed - continuing. {0} {1}",
|
||||
e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//end of SYMMETRIC SYNC
|
||||
}
|
||||
}
|
||||
|
|
|
@ -821,7 +821,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_physicalPrim = physicalPrim;
|
||||
m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
|
||||
|
||||
m_eventManager = new EventManager();
|
||||
//SYMMETRIC SYNC: pass Scene reference to EventManager
|
||||
//m_eventManager = new EventManager();
|
||||
m_eventManager = new EventManager(this);
|
||||
//end of SYMMETRIC SYNC
|
||||
m_permissions = new ScenePermissions(this);
|
||||
|
||||
m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
|
||||
|
@ -1029,7 +1032,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
BordersLocked = false;
|
||||
|
||||
m_regInfo = regInfo;
|
||||
m_eventManager = new EventManager();
|
||||
|
||||
//SYMMETRIC SYNC: pass Scene reference to EventManager
|
||||
//m_eventManager = new EventManager();
|
||||
m_eventManager = new EventManager(this);
|
||||
//end of SYMMETRIC SYNC
|
||||
|
||||
m_lastUpdate = Util.EnvironmentTickCount();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue