aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-26 17:01:33 +0000
committerMelanie Thielker2008-09-26 17:01:33 +0000
commit34cfd710ce2f80e11012a219af73100f559306df (patch)
treea9ecd356aed4f1cae2c9368b96290319c4033a0f /OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
parentAdds support for the "Running" checkbox and the "Reset" button, as well as (diff)
downloadopensim-SC-34cfd710ce2f80e11012a219af73100f559306df.zip
opensim-SC-34cfd710ce2f80e11012a219af73100f559306df.tar.gz
opensim-SC-34cfd710ce2f80e11012a219af73100f559306df.tar.bz2
opensim-SC-34cfd710ce2f80e11012a219af73100f559306df.tar.xz
DNE code cleanups
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs68
1 files changed, 43 insertions, 25 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index 71db4ee..ee64c41 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -44,19 +44,35 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
44 [Serializable] 44 [Serializable]
45 public class ScriptEngine : IRegionModule, IEventReceiver, IScriptModule 45 public class ScriptEngine : IRegionModule, IEventReceiver, IScriptModule
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 public static List<ScriptEngine> ScriptEngines =
52 new List<ScriptEngine>();
48 53
49 public static List<ScriptEngine> ScriptEngines = new List<ScriptEngine>();
50 private Scene m_Scene; 54 private Scene m_Scene;
51 public Scene World 55 public Scene World
52 { 56 {
53 get { return m_Scene; } 57 get { return m_Scene; }
54 } 58 }
55 public EventManager m_EventManager; // Handles and queues incoming events from OpenSim 59
56 public EventQueueManager m_EventQueueManager; // Executes events, handles script threads 60 // Handles and queues incoming events from OpenSim
57 public ScriptManager m_ScriptManager; // Load, unload and execute scripts 61 public EventManager m_EventManager;
58 public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains 62
59 public static MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long 63 // Executes events, handles script threads
64 public EventQueueManager m_EventQueueManager;
65
66 // Load, unload and execute scripts
67 public ScriptManager m_ScriptManager;
68
69 // Handles loading/unloading of scripts into AppDomains
70 public AppDomainManager m_AppDomainManager;
71
72 // Thread that does different kinds of maintenance,
73 // for example refreshing config and killing scripts
74 // that has been running too long
75 public static MaintenanceThread m_MaintenanceThread;
60 76
61 public IConfigSource ConfigSource; 77 public IConfigSource ConfigSource;
62 public IConfig ScriptConfigSource; 78 public IConfig ScriptConfigSource;
@@ -67,13 +83,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
67 get { return ScriptConfigSource; } 83 get { return ScriptConfigSource; }
68 } 84 }
69 85
70 /// <summary> 86 // How many seconds between re-reading config-file.
71 /// How many seconds between re-reading config-file. 0 = never. ScriptEngine will try to adjust to new config changes. 87 // 0 = never. ScriptEngine will try to adjust to new config changes.
72 /// </summary>
73 public int RefreshConfigFileSeconds { 88 public int RefreshConfigFileSeconds {
74 get { return (int)(RefreshConfigFilens / 10000000); } 89 get { return (int)(RefreshConfigFilens / 10000000); }
75 set { RefreshConfigFilens = value * 10000000; } 90 set { RefreshConfigFilens = value * 10000000; }
76 } 91 }
92
77 public long RefreshConfigFilens; 93 public long RefreshConfigFilens;
78 94
79 public string ScriptEngineName 95 public string ScriptEngineName
@@ -88,10 +104,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
88 104
89 public ScriptEngine() 105 public ScriptEngine()
90 { 106 {
91 Common.mySE = this; // For logging, just need any instance, doesn't matter 107 // For logging, just need any instance, doesn't matter
108 Common.mySE = this;
109
92 lock (ScriptEngines) 110 lock (ScriptEngines)
93 { 111 {
94 ScriptEngines.Add(this); // Keep a list of ScriptEngines for shared threads to process all instances 112 // Keep a list of ScriptEngines for shared threads
113 // to process all instances
114 ScriptEngines.Add(this);
95 } 115 }
96 } 116 }
97 117
@@ -105,17 +125,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
105 // Make sure we have config 125 // Make sure we have config
106 if (ConfigSource.Configs[ScriptEngineName] == null) 126 if (ConfigSource.Configs[ScriptEngineName] == null)
107 ConfigSource.AddConfig(ScriptEngineName); 127 ConfigSource.AddConfig(ScriptEngineName);
128
108 ScriptConfigSource = ConfigSource.Configs[ScriptEngineName]; 129 ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
109 130
110 m_enabled = ScriptConfigSource.GetBoolean("Enabled", true); 131 m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
111 if (!m_enabled) 132 if (!m_enabled)
112 return; 133 return;
113 134
114 //m_log.Info("[" + ScriptEngineName + "]: InitializeEngine");
115
116 // Create all objects we'll be using 135 // Create all objects we'll be using
117 m_EventQueueManager = new EventQueueManager(this); 136 m_EventQueueManager = new EventQueueManager(this);
118 m_EventManager = new EventManager(this, true); 137 m_EventManager = new EventManager(this, true);
138
119 // We need to start it 139 // We need to start it
120 m_ScriptManager = new ScriptManager(this); 140 m_ScriptManager = new ScriptManager(this);
121 m_ScriptManager.Setup(); 141 m_ScriptManager.Setup();
@@ -123,7 +143,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
123 if (m_MaintenanceThread == null) 143 if (m_MaintenanceThread == null)
124 m_MaintenanceThread = new MaintenanceThread(); 144 m_MaintenanceThread = new MaintenanceThread();
125 145
126 m_log.Info("[" + ScriptEngineName + "]: Reading configuration from config section \"" + ScriptEngineName + "\""); 146 m_log.Info("[" + ScriptEngineName + "]: Reading configuration "+
147 "from config section \"" + ScriptEngineName + "\"");
148
127 ReadConfig(); 149 ReadConfig();
128 150
129 m_Scene.StackModuleInterface<IScriptModule>(this); 151 m_Scene.StackModuleInterface<IScriptModule>(this);
@@ -155,15 +177,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
155 177
156 public void ReadConfig() 178 public void ReadConfig()
157 { 179 {
158#if DEBUG
159 //m_log.Debug("[" + ScriptEngineName + "]: Refreshing configuration for all modules");
160#endif
161 RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30); 180 RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30);
162 181
163
164 // Create a new object (probably not necessary?)
165// ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
166
167 if (m_EventQueueManager != null) m_EventQueueManager.ReadConfig(); 182 if (m_EventQueueManager != null) m_EventQueueManager.ReadConfig();
168 if (m_EventManager != null) m_EventManager.ReadConfig(); 183 if (m_EventManager != null) m_EventManager.ReadConfig();
169 if (m_ScriptManager != null) m_ScriptManager.ReadConfig(); 184 if (m_ScriptManager != null) m_ScriptManager.ReadConfig();
@@ -189,13 +204,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
189 204
190 public bool PostObjectEvent(uint localID, EventParams p) 205 public bool PostObjectEvent(uint localID, EventParams p)
191 { 206 {
192 return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, p.DetectParams, p.Params); 207 return m_EventQueueManager.AddToObjectQueue(localID, p.EventName,
208 p.DetectParams, p.Params);
193 } 209 }
194 210
195 public bool PostScriptEvent(UUID itemID, EventParams p) 211 public bool PostScriptEvent(UUID itemID, EventParams p)
196 { 212 {
197 uint localID = m_ScriptManager.GetLocalID(itemID); 213 uint localID = m_ScriptManager.GetLocalID(itemID);
198 return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, p.DetectParams, p.Params); 214 return m_EventQueueManager.AddToScriptQueue(localID, itemID,
215 p.EventName, p.DetectParams, p.Params);
199 } 216 }
200 217
201 public DetectParams GetDetectParams(UUID itemID, int number) 218 public DetectParams GetDetectParams(UUID itemID, int number)
@@ -341,7 +358,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
341 id.Running = false; 358 id.Running = false;
342 } 359 }
343 360
344 public void OnGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 361 public void OnGetScriptRunning(IClientAPI controllingClient,
362 UUID objectID, UUID itemID)
345 { 363 {
346 uint localID = m_ScriptManager.GetLocalID(itemID); 364 uint localID = m_ScriptManager.GetLocalID(itemID);
347 if (localID == 0) 365 if (localID == 0)