From 6425680cff72e728045a698e84a17dcb85272f9a Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Tue, 23 Sep 2008 17:33:00 +0000
Subject: Add IEventReceiver to DNE - a consolidation series patch
---
.../Common/ScriptEngineBase/EventQueueManager.cs | 14 ++++++++------
.../Common/ScriptEngineBase/ScriptEngine.cs | 15 ++++++++++++++-
.../Common/ScriptEngineBase/ScriptManager.cs | 18 ++++++++++++++++--
3 files changed, 38 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase')
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
index d0af720..ac0ab7e 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs
@@ -322,7 +322,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// Region object ID
/// Name of the function, will be state + "_event_" + FunctionName
/// Array of parameters to match event mask
- public void AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
+ public bool AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
{
// Determine all scripts in Object and add to their queue
//myScriptEngine.log.Info("[" + ScriptEngineName + "]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
@@ -331,10 +331,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
if (m_ScriptEngine.m_ScriptManager.Scripts.ContainsKey(localID) == false)
{
//Console.WriteLine("Event \String.Empty + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
- return;
+ return false;
}
- Dictionary.KeyCollection scriptKeys =
+ List scriptKeys =
m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
foreach (UUID itemID in scriptKeys)
@@ -343,6 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter?
AddToScriptQueue(localID, itemID, FunctionName, qParams, param);
}
+ return true;
}
///
@@ -352,12 +353,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// Region script ID
/// Name of the function, will be state + "_event_" + FunctionName
/// Array of parameters to match event mask
- public void AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
+ public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
{
List keylist = new List(m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID));
if (!keylist.Contains(itemID)) // We don't manage that script
- return;
+ return false;
lock (eventQueue)
{
@@ -365,7 +366,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{
m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: ERROR: Event execution queue item count is at " + eventQueue.Count + ". Config variable \"EventExecutionMaxQueueSize\" is set to " + EventExecutionMaxQueueSize + ", so ignoring new event.");
m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Event ignored: localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
- return;
+ return false;
}
// Create a structure and add data
@@ -379,6 +380,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// Add it to queue
eventQueue.Enqueue(QIS);
}
+ return true;
}
#endregion
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
index af29dc8..79f521d 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
@@ -32,6 +32,9 @@ using log4net;
using Nini.Config;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
+using OpenSim.Region.ScriptEngine.Interfaces;
+using OpenMetaverse;
+using OpenSim.Region.ScriptEngine.Shared;
namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{
@@ -40,7 +43,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
///
///
[Serializable]
- public abstract class ScriptEngine : IRegionModule, ScriptServerInterfaces.ScriptEngine, iScriptEngineFunctionModule
+ public abstract class ScriptEngine : IRegionModule, ScriptServerInterfaces.ScriptEngine, iScriptEngineFunctionModule, IEventReceiver
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -187,6 +190,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
get { return false; }
}
+ public bool PostObjectEvent(uint localID, EventParams p)
+ {
+ return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, EventQueueManager.llDetectNull, p.Params);
+ }
+
+ public bool PostScriptEvent(UUID itemID, EventParams p)
+ {
+ return m_EventQueueManager.AddToScriptQueue(0, itemID, p.EventName, EventQueueManager.llDetectNull, p.Params);
+ }
+
#endregion
}
}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
index 47cb2fd..8d4dc56 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs
@@ -366,15 +366,29 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
#region Internal functions to keep track of script
- public Dictionary.KeyCollection GetScriptKeys(uint localID)
+ public List GetScriptKeys(uint localID)
{
+ if (localID == 0) // Find it
+ {
+ List keylist = new List();
+
+ foreach (Dictionary d in Scripts.Values)
+ {
+ foreach (UUID id in d.Keys)
+ {
+ if (!keylist.Contains(id))
+ keylist.Add(id);
+ }
+ }
+ }
+
if (Scripts.ContainsKey(localID) == false)
return null;
Dictionary Obj;
Scripts.TryGetValue(localID, out Obj);
- return Obj.Keys;
+ return new List(Obj.Keys);
}
public IScript GetScript(uint localID, UUID itemID)
--
cgit v1.1