diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/Executor.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/Executor.cs | 64 |
1 files changed, 4 insertions, 60 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index 6262c64..e35882b 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs | |||
@@ -33,64 +33,26 @@ using System.Runtime.Remoting.Lifetime; | |||
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.Common | 34 | namespace OpenSim.Region.ScriptEngine.Common |
35 | { | 35 | { |
36 | public class Executor : MarshalByRefObject | 36 | public class Executor : ExecutorBase |
37 | { | 37 | { |
38 | // Private instance for each script | 38 | // Cache functions by keeping a reference to them in a dictionary |
39 | |||
40 | private IScript m_Script; | ||
41 | private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); | 39 | private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); |
42 | private bool m_Running = true; | ||
43 | //private List<IScript> Scripts = new List<IScript>(); | ||
44 | 40 | ||
45 | public Executor(IScript Script) | 41 | public Executor(IScript script) : base(script) |
46 | { | 42 | { |
47 | m_Script = Script; | ||
48 | } | 43 | } |
49 | 44 | ||
50 | // Object never expires | 45 | protected override void DoExecuteEvent(string FunctionName, object[] args) |
51 | public override Object InitializeLifetimeService() | ||
52 | { | ||
53 | //Console.WriteLine("Executor: InitializeLifetimeService()"); | ||
54 | // return null; | ||
55 | ILease lease = (ILease) base.InitializeLifetimeService(); | ||
56 | |||
57 | if (lease.CurrentState == LeaseState.Initial) | ||
58 | { | ||
59 | lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); | ||
60 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | ||
61 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
62 | } | ||
63 | return lease; | ||
64 | } | ||
65 | |||
66 | public AppDomain GetAppDomain() | ||
67 | { | ||
68 | return AppDomain.CurrentDomain; | ||
69 | } | ||
70 | |||
71 | public void ExecuteEvent(string FunctionName, object[] args) | ||
72 | { | 46 | { |
73 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 47 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
74 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! | 48 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! |
75 | //try | ||
76 | //{ | ||
77 | if (m_Running == false) | ||
78 | { | ||
79 | // Script is inactive, do not execute! | ||
80 | return; | ||
81 | } | ||
82 | 49 | ||
83 | string EventName = m_Script.State + "_event_" + FunctionName; | 50 | string EventName = m_Script.State + "_event_" + FunctionName; |
84 | 51 | ||
85 | //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined | ||
86 | ///#if DEBUG | 52 | ///#if DEBUG |
87 | /// Console.WriteLine("ScriptEngine: Script event function name: " + EventName); | 53 | /// Console.WriteLine("ScriptEngine: Script event function name: " + EventName); |
88 | ///#endif | 54 | ///#endif |
89 | 55 | ||
90 | //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); | ||
91 | |||
92 | //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \String.Empty + EventName + "\String.Empty); | ||
93 | |||
94 | if (Events.ContainsKey(EventName) == false) | 56 | if (Events.ContainsKey(EventName) == false) |
95 | { | 57 | { |
96 | // Not found, create | 58 | // Not found, create |
@@ -122,27 +84,9 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
122 | /// Console.WriteLine("ScriptEngine: Executing function name: " + EventName); | 84 | /// Console.WriteLine("ScriptEngine: Executing function name: " + EventName); |
123 | ///#endif | 85 | ///#endif |
124 | // Found | 86 | // Found |
125 | //try | ||
126 | //{ | ||
127 | // Invoke it | ||
128 | ev.Invoke(m_Script, args); | 87 | ev.Invoke(m_Script, args); |
129 | 88 | ||
130 | //} | ||
131 | //catch (Exception e) | ||
132 | //{ | ||
133 | // // TODO: Send to correct place | ||
134 | // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); | ||
135 | //} | ||
136 | |||
137 | |||
138 | //} | ||
139 | //catch { } | ||
140 | } | 89 | } |
141 | 90 | ||
142 | |||
143 | public void StopScript() | ||
144 | { | ||
145 | m_Running = false; | ||
146 | } | ||
147 | } | 91 | } |
148 | } \ No newline at end of file | 92 | } \ No newline at end of file |