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;
|
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
||||||
InstallInterfaces();
|
InstallInterfaces();
|
||||||
|
|
||||||
//Register for Scene events
|
//Register for local Scene events
|
||||||
m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
|
m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
|
||||||
m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene);
|
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
|
//Called after AddRegion() has been called for all region modules of the scene
|
||||||
|
@ -842,9 +840,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//EVENTS PROCESSING
|
//EVENTS PROCESSING
|
||||||
case SymmetricSyncMessage.MsgType.OnUpdateScript:
|
case SymmetricSyncMessage.MsgType.UpdateScript:
|
||||||
{
|
{
|
||||||
HandleEvent_OnUpdateScript(msg);
|
HandleRemoteEvent_OnUpdateScript(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -980,7 +978,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
/// Handler for SymmetricSyncMessage.MsgType.OnUpdateScript
|
/// Handler for SymmetricSyncMessage.MsgType.OnUpdateScript
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="msg"></param>
|
/// <param name="msg"></param>
|
||||||
private void HandleEvent_OnUpdateScript(SymmetricSyncMessage msg)
|
private void HandleRemoteEvent_OnUpdateScript(SymmetricSyncMessage msg)
|
||||||
{
|
{
|
||||||
m_log.Debug(LogHeader + ", " + m_actorID + ": received OnUpdateScript");
|
m_log.Debug(LogHeader + ", " + m_actorID + ": received OnUpdateScript");
|
||||||
|
|
||||||
|
@ -993,10 +991,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
UUID primID = data["primID"].AsUUID();
|
UUID primID = data["primID"].AsUUID();
|
||||||
bool isRunning = data["running"].AsBoolean();
|
bool isRunning = data["running"].AsBoolean();
|
||||||
UUID assetID = data["assetID"].AsUUID();
|
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
|
//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
|
//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>
|
/// <summary>
|
||||||
/// The handler for (locally initiated) event OnUpdateScript: publish it to other actors.
|
/// The handler for (locally initiated) event OnUpdateScript: publish it to other actors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1039,7 +1055,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
/// <param name="primId"></param>
|
/// <param name="primId"></param>
|
||||||
/// <param name="isScriptRunning"></param>
|
/// <param name="isScriptRunning"></param>
|
||||||
/// <param name="newAssetID"></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");
|
m_log.Debug(LogHeader + " RegionSyncModule_OnUpdateScript");
|
||||||
|
|
||||||
|
@ -1050,9 +1066,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
data["running"] = OSD.FromBoolean(isScriptRunning);
|
data["running"] = OSD.FromBoolean(isScriptRunning);
|
||||||
data["assetID"] = OSD.FromUUID(newAssetID);
|
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)
|
private void PublishSceneEvent(OSDMap data)
|
||||||
{
|
{
|
||||||
data["actorID"] = OSD.FromString(m_actorID);
|
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));
|
SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.OnUpdateScript, OSDParser.SerializeJsonString(data));
|
||||||
SendSceneEventToRelevantSyncConnectors(m_actorID, rsm);
|
SendSceneEventToRelevantSyncConnectors(m_actorID, rsm);
|
||||||
}
|
}
|
||||||
|
* */
|
||||||
|
|
||||||
private ulong GetNextEventSeq()
|
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.
|
//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.
|
//RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors.
|
||||||
m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript;
|
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.
|
//Called after AddRegion() has been called for all region modules of the scene.
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
//RegionStatus,
|
//RegionStatus,
|
||||||
ActorID,
|
ActorID,
|
||||||
//events
|
//events
|
||||||
OnUpdateScript,
|
UpdateScript,
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//KittyL: Added to support running script engine actor
|
//KittyL: Added to support running script engine actor
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
@ -65,6 +65,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
void SendTerrainUpdates(string lastUpdateActorID);
|
void SendTerrainUpdates(string lastUpdateActorID);
|
||||||
//void SendDeleteObject(SceneObjectGroup sog);
|
//void SendDeleteObject(SceneObjectGroup sog);
|
||||||
|
|
||||||
|
//For propogating scene events to other actors
|
||||||
|
void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs);
|
||||||
|
|
||||||
//TODO LIST:
|
//TODO LIST:
|
||||||
//Special API for handling avatars
|
//Special API for handling avatars
|
||||||
//void QueuePresenceForTerseUpdate(ScenePresence presence)
|
//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
|
//SYMMETRIC SYNC: Rename the original EventManager as EventManagerBase, and implement a new EventManager that inherits from EventManagerBase
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </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);
|
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
|
//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 delegate void UpdateScript(UUID clientID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID);
|
||||||
public event UpdateScript OnUpdateScript;
|
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;
|
UpdateScript handlerUpdateScript = OnUpdateScript;
|
||||||
if (handlerUpdateScript != null)
|
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
|
//end of SYMMETRIC SYNC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -821,7 +821,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_physicalPrim = physicalPrim;
|
m_physicalPrim = physicalPrim;
|
||||||
m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
|
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_permissions = new ScenePermissions(this);
|
||||||
|
|
||||||
m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
|
m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
|
||||||
|
@ -1029,7 +1032,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
BordersLocked = false;
|
BordersLocked = false;
|
||||||
|
|
||||||
m_regInfo = regInfo;
|
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();
|
m_lastUpdate = Util.EnvironmentTickCount();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue