aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/Executor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/Executor.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Executor.cs230
1 files changed, 115 insertions, 115 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs
index d165722..1849085 100644
--- a/OpenSim/Region/ScriptEngine/Common/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs
@@ -1,115 +1,115 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Reflection; 4using System.Reflection;
5using System.Runtime.Remoting.Lifetime; 5using System.Runtime.Remoting.Lifetime;
6 6
7namespace OpenSim.Region.ScriptEngine.Common 7namespace OpenSim.Region.ScriptEngine.Common
8{ 8{
9 public class Executor : MarshalByRefObject 9 public class Executor : MarshalByRefObject
10 { 10 {
11 // Private instance for each script 11 // Private instance for each script
12 12
13 private IScript m_Script; 13 private IScript m_Script;
14 private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); 14 private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>();
15 private bool m_Running = true; 15 private bool m_Running = true;
16 //private List<IScript> Scripts = new List<IScript>(); 16 //private List<IScript> Scripts = new List<IScript>();
17 17
18 public Executor(IScript Script) 18 public Executor(IScript Script)
19 { 19 {
20 m_Script = Script; 20 m_Script = Script;
21 } 21 }
22 22
23 // Object never expires 23 // Object never expires
24 public override Object InitializeLifetimeService() 24 public override Object InitializeLifetimeService()
25 { 25 {
26 //Console.WriteLine("Executor: InitializeLifetimeService()"); 26 //Console.WriteLine("Executor: InitializeLifetimeService()");
27 // return null; 27 // return null;
28 ILease lease = (ILease)base.InitializeLifetimeService(); 28 ILease lease = (ILease)base.InitializeLifetimeService();
29 29
30 if (lease.CurrentState == LeaseState.Initial) 30 if (lease.CurrentState == LeaseState.Initial)
31 { 31 {
32 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); 32 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
33// lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); 33// lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
34// lease.RenewOnCallTime = TimeSpan.FromSeconds(2); 34// lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
35 } 35 }
36 return lease; 36 return lease;
37 } 37 }
38 38
39 public AppDomain GetAppDomain() 39 public AppDomain GetAppDomain()
40 { 40 {
41 return AppDomain.CurrentDomain; 41 return AppDomain.CurrentDomain;
42 } 42 }
43 43
44 public void ExecuteEvent(string FunctionName, object[] args) 44 public void ExecuteEvent(string FunctionName, object[] args)
45 { 45 {
46 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 46 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
47 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! 47 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
48 //try 48 //try
49 //{ 49 //{
50 if (m_Running == false) 50 if (m_Running == false)
51 { 51 {
52 // Script is inactive, do not execute! 52 // Script is inactive, do not execute!
53 return; 53 return;
54 } 54 }
55 55
56 string EventName = m_Script.State() + "_event_" + FunctionName; 56 string EventName = m_Script.State() + "_event_" + FunctionName;
57 57
58 //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); 58 //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args);
59 59
60 //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); 60 //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\"");
61 61
62 if (Events.ContainsKey(EventName) == false) 62 if (Events.ContainsKey(EventName) == false)
63 { 63 {
64 // Not found, create 64 // Not found, create
65 Type type = m_Script.GetType(); 65 Type type = m_Script.GetType();
66 try 66 try
67 { 67 {
68 MethodInfo mi = type.GetMethod(EventName); 68 MethodInfo mi = type.GetMethod(EventName);
69 Events.Add(EventName, mi); 69 Events.Add(EventName, mi);
70 } 70 }
71 catch 71 catch
72 { 72 {
73 // Event name not found, cache it as not found 73 // Event name not found, cache it as not found
74 Events.Add(EventName, null); 74 Events.Add(EventName, null);
75 } 75 }
76 } 76 }
77 77
78 // Get event 78 // Get event
79 MethodInfo ev = null; 79 MethodInfo ev = null;
80 Events.TryGetValue(EventName, out ev); 80 Events.TryGetValue(EventName, out ev);
81 81
82 if (ev == null) // No event by that name! 82 if (ev == null) // No event by that name!
83 { 83 {
84 //Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); 84 //Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\"");
85 return; 85 return;
86 } 86 }
87 87
88 // Found 88 // Found
89 //try 89 //try
90 //{ 90 //{
91 // Invoke it 91 // Invoke it
92 ev.Invoke(m_Script, args); 92 ev.Invoke(m_Script, args);
93 93
94 //} 94 //}
95 //catch (Exception e) 95 //catch (Exception e)
96 //{ 96 //{
97 // // TODO: Send to correct place 97 // // TODO: Send to correct place
98 // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); 98 // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
99 //} 99 //}
100 100
101 101
102 //} 102 //}
103 //catch { } 103 //catch { }
104 } 104 }
105 105
106 106
107 public void StopScript() 107 public void StopScript()
108 { 108 {
109 m_Running = false; 109 m_Running = false;
110 } 110 }
111 111
112 112
113 } 113 }
114 114
115} 115}