Add IEventReceiver to DNE - a consolidation series patch

0.6.0-stable
Melanie Thielker 2008-09-23 17:33:00 +00:00
parent 420a645036
commit 6425680cff
3 changed files with 38 additions and 9 deletions

View File

@ -322,7 +322,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// <param name="localID">Region object ID</param>
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
/// <param name="param">Array of parameters to match event mask</param>
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<UUID, IScript>.KeyCollection scriptKeys =
List<UUID> 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;
}
/// <summary>
@ -352,12 +353,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// <param name="itemID">Region script ID</param>
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
/// <param name="param">Array of parameters to match event mask</param>
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<UUID> keylist = new List<UUID>(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

View File

@ -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
/// </summary>
///
[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
}
}

View File

@ -366,15 +366,29 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
#region Internal functions to keep track of script
public Dictionary<UUID, IScript>.KeyCollection GetScriptKeys(uint localID)
public List<UUID> GetScriptKeys(uint localID)
{
if (localID == 0) // Find it
{
List<UUID> keylist = new List<UUID>();
foreach (Dictionary<UUID, IScript> 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<UUID, IScript> Obj;
Scripts.TryGetValue(localID, out Obj);
return Obj.Keys;
return new List<UUID>(Obj.Keys);
}
public IScript GetScript(uint localID, UUID itemID)