From b75c1b2191640f4a140dc4cd0e8ce35ab64863d9 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 25 Aug 2007 19:08:15 +0000 Subject: Added class for "long commands" (command that returns as event) with dedicated thread for processing. Added support for llSetTimerEvent(). Deleting old compiled scripts before new compile is attempted (avoids loading wrong script on compile error). --- OpenSim/Region/ScriptEngine/Common/Executor.cs | 80 ++++++++++++++------------ 1 file changed, 43 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common') diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index cadd55c..363d81e 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -23,7 +23,7 @@ namespace OpenSim.Region.ScriptEngine.Common // Object never expires public override Object InitializeLifetimeService() { - Console.WriteLine("Executor: InitializeLifetimeService()"); + //Console.WriteLine("Executor: InitializeLifetimeService()"); // return null; ILease lease = (ILease)base.InitializeLifetimeService(); @@ -45,54 +45,60 @@ namespace OpenSim.Region.ScriptEngine.Common { // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! - - if (m_Running == false) + try { - // Script is inactive, do not execute! - return; - } + if (m_Running == false) + { + // Script is inactive, do not execute! + return; + } - string EventName = m_Script.State() + "_event_" + FunctionName; + string EventName = m_Script.State() + "_event_" + FunctionName; - //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); + //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); - Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); + Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); - if (Events.ContainsKey(EventName) == false) - { - // Not found, create - Type type = m_Script.GetType(); - try - { - MethodInfo mi = type.GetMethod(EventName); - Events.Add(EventName, mi); - } - catch (Exception e) + if (Events.ContainsKey(EventName) == false) { - // Event name not found, cache it as not found - Events.Add(EventName, null); + // Not found, create + Type type = m_Script.GetType(); + try + { + MethodInfo mi = type.GetMethod(EventName); + Events.Add(EventName, mi); + } + catch (Exception e) + { + // Event name not found, cache it as not found + Events.Add(EventName, null); + } } - } - // Get event - MethodInfo ev = null; - Events.TryGetValue(EventName, out ev); + // Get event + MethodInfo ev = null; + Events.TryGetValue(EventName, out ev); - if (ev == null) // No event by that name! - return; + if (ev == null) // No event by that name! + { + Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); + return; + } - // Found - try - { - // Invoke it - ev.Invoke(m_Script, args); + // Found + try + { + // Invoke it + ev.Invoke(m_Script, args); + } + catch (Exception e) + { + // TODO: Send to correct place + Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); + } } - catch (Exception e) - { - // TODO: Send to correct place - Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); - } + catch { } } -- cgit v1.1