aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-25 05:13:44 +0000
committerMelanie Thielker2008-09-25 05:13:44 +0000
commitf3c8963c86dbc969541ede80ae37eb59d26b7809 (patch)
treeff1e5cea74e9d5c2b73c476320a7bddf11d93766 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
parentMantis#2123. Thank you kindly, Idb for a patch that solves: (diff)
downloadopensim-SC-f3c8963c86dbc969541ede80ae37eb59d26b7809.zip
opensim-SC-f3c8963c86dbc969541ede80ae37eb59d26b7809.tar.gz
opensim-SC-f3c8963c86dbc969541ede80ae37eb59d26b7809.tar.bz2
opensim-SC-f3c8963c86dbc969541ede80ae37eb59d26b7809.tar.xz
Convergence is almost complete. This brings the diff between the API to < 10k
and makes it use a common set of types in both engine. Fixes the issues with running both engines and HTTP requests / listens / timers etc.. Also fixes a couple of minor Scene issues and a CTB by nullref.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs116
1 files changed, 61 insertions, 55 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 020e64a..91ca298 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -54,47 +54,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
54 public IEventReceiver m_ScriptEngine; 54 public IEventReceiver m_ScriptEngine;
55 private IScene m_Scene; 55 private IScene m_Scene;
56 56
57 private static Dictionary<IScene, Dataserver> m_Dataserver = 57 private static Dictionary<IEventReceiver, Dataserver> m_Dataserver =
58 new Dictionary<IScene, Dataserver>(); 58 new Dictionary<IEventReceiver, Dataserver>();
59 private static Dictionary<IScene, Timer> m_Timer = 59 private static Dictionary<IEventReceiver, Timer> m_Timer =
60 new Dictionary<IScene, Timer>(); 60 new Dictionary<IEventReceiver, Timer>();
61 private static Dictionary<IScene, Listener> m_Listener = 61 private static Dictionary<IEventReceiver, Listener> m_Listener =
62 new Dictionary<IScene, Listener>(); 62 new Dictionary<IEventReceiver, Listener>();
63 private static Dictionary<IScene, HttpRequest> m_HttpRequest = 63 private static Dictionary<IEventReceiver, HttpRequest> m_HttpRequest =
64 new Dictionary<IScene, HttpRequest>(); 64 new Dictionary<IEventReceiver, HttpRequest>();
65 private static Dictionary<IScene, SensorRepeat> m_SensorRepeat = 65 private static Dictionary<IEventReceiver, SensorRepeat> m_SensorRepeat =
66 new Dictionary<IScene, SensorRepeat>(); 66 new Dictionary<IEventReceiver, SensorRepeat>();
67 private static Dictionary<IScene, XmlRequest> m_XmlRequest = 67 private static Dictionary<IEventReceiver, XmlRequest> m_XmlRequest =
68 new Dictionary<IScene, XmlRequest>(); 68 new Dictionary<IEventReceiver, XmlRequest>();
69 69
70 public Dataserver DataserverPlugin 70 public Dataserver DataserverPlugin
71 { 71 {
72 get { return m_Dataserver[m_Scene]; } 72 get { return m_Dataserver[m_ScriptEngine]; }
73 } 73 }
74 74
75 public Timer TimerPlugin 75 public Timer TimerPlugin
76 { 76 {
77 get { return m_Timer[m_Scene]; } 77 get { return m_Timer[m_ScriptEngine]; }
78 } 78 }
79 79
80 public HttpRequest HttpRequestPlugin 80 public HttpRequest HttpRequestPlugin
81 { 81 {
82 get { return m_HttpRequest[m_Scene]; } 82 get { return m_HttpRequest[m_ScriptEngine]; }
83 } 83 }
84 84
85 public Listener ListenerPlugin 85 public Listener ListenerPlugin
86 { 86 {
87 get { return m_Listener[m_Scene]; } 87 get { return m_Listener[m_ScriptEngine]; }
88 } 88 }
89 89
90 public SensorRepeat SensorRepeatPlugin 90 public SensorRepeat SensorRepeatPlugin
91 { 91 {
92 get { return m_SensorRepeat[m_Scene]; } 92 get { return m_SensorRepeat[m_ScriptEngine]; }
93 } 93 }
94 94
95 public XmlRequest XmlRequestPlugin 95 public XmlRequest XmlRequestPlugin
96 { 96 {
97 get { return m_XmlRequest[m_Scene]; } 97 get { return m_XmlRequest[m_ScriptEngine]; }
98 } 98 }
99 99
100 public IEventReceiver[] ScriptEngines 100 public IEventReceiver[] ScriptEngines
@@ -107,26 +107,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
107 m_ScriptEngine = _ScriptEngine; 107 m_ScriptEngine = _ScriptEngine;
108 m_Scene = m_ScriptEngine.World; 108 m_Scene = m_ScriptEngine.World;
109 109
110 if (m_Scenes.Count == 0)
111 ReadConfig();
112
110 if (!m_Scenes.Contains(m_Scene)) 113 if (!m_Scenes.Contains(m_Scene))
111 m_Scenes.Add(m_Scene); 114 m_Scenes.Add(m_Scene);
112 if (!m_ScriptEngines.Contains(m_ScriptEngine)) 115 if (!m_ScriptEngines.Contains(m_ScriptEngine))
113 m_ScriptEngines.Add(m_ScriptEngine); 116 m_ScriptEngines.Add(m_ScriptEngine);
114 117
115 ReadConfig();
116
117 // Create instances of all plugins 118 // Create instances of all plugins
118 if (!m_Dataserver.ContainsKey(m_Scene)) 119 if (!m_Dataserver.ContainsKey(m_ScriptEngine))
119 m_Dataserver[m_Scene] = new Dataserver(this); 120 m_Dataserver[m_ScriptEngine] = new Dataserver(this);
120 if (!m_Timer.ContainsKey(m_Scene)) 121 if (!m_Timer.ContainsKey(m_ScriptEngine))
121 m_Timer[m_Scene] = new Timer(this); 122 m_Timer[m_ScriptEngine] = new Timer(this);
122 if (!m_HttpRequest.ContainsKey(m_Scene)) 123 if (!m_HttpRequest.ContainsKey(m_ScriptEngine))
123 m_HttpRequest[m_Scene] = new HttpRequest(this); 124 m_HttpRequest[m_ScriptEngine] = new HttpRequest(this);
124 if (!m_Listener.ContainsKey(m_Scene)) 125 if (!m_Listener.ContainsKey(m_ScriptEngine))
125 m_Listener[m_Scene] = new Listener(this); 126 m_Listener[m_ScriptEngine] = new Listener(this);
126 if (!m_SensorRepeat.ContainsKey(m_Scene)) 127 if (!m_SensorRepeat.ContainsKey(m_ScriptEngine))
127 m_SensorRepeat[m_Scene] = new SensorRepeat(this); 128 m_SensorRepeat[m_ScriptEngine] = new SensorRepeat(this);
128 if (!m_XmlRequest.ContainsKey(m_Scene)) 129 if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
129 m_XmlRequest[m_Scene] = new XmlRequest(this); 130 m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
130 131
131 StartThread(); 132 StartThread();
132 } 133 }
@@ -145,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
145 } 146 }
146 } 147 }
147 148
148 public void ReadConfig() 149 private void ReadConfig()
149 { 150 {
150// cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100); 151// cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100);
151 // TODO: Make this sane again 152 // TODO: Make this sane again
@@ -195,18 +196,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
195 196
196 private static void DoOneCmdHandlerPass() 197 private static void DoOneCmdHandlerPass()
197 { 198 {
198 foreach (IScene s in m_Scenes) 199 // Check Listeners
200 m_Listener[m_ScriptEngines[0]].CheckListeners();
201
202 // Check HttpRequests
203 m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests();
204
205 // Check XMLRPCRequests
206 m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests();
207
208 foreach (IEventReceiver s in m_ScriptEngines)
199 { 209 {
200 // Check timers 210 // Check timers
201 m_Timer[s].CheckTimerEvents(); 211 m_Timer[s].CheckTimerEvents();
202 // Check HttpRequests 212
203 m_HttpRequest[s].CheckHttpRequests();
204 // Check XMLRPCRequests
205 m_XmlRequest[s].CheckXMLRPCRequests();
206 // Check Listeners
207 m_Listener[s].CheckListeners();
208 // Check Sensors 213 // Check Sensors
209 m_SensorRepeat[s].CheckSenseRepeaterEvents(); 214 m_SensorRepeat[s].CheckSenseRepeaterEvents();
215
210 // Check dataserver 216 // Check dataserver
211 m_Dataserver[s].ExpireRequests(); 217 m_Dataserver[s].ExpireRequests();
212 } 218 }
@@ -217,38 +223,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
217 /// </summary> 223 /// </summary>
218 /// <param name="localID"></param> 224 /// <param name="localID"></param>
219 /// <param name="itemID"></param> 225 /// <param name="itemID"></param>
220 public static void RemoveScript(IScene scene, uint localID, UUID itemID) 226 public static void RemoveScript(IEventReceiver engine, uint localID, UUID itemID)
221 { 227 {
222 // Remove a specific script 228 // Remove a specific script
223 229
224 // Remove dataserver events 230 // Remove dataserver events
225 m_Dataserver[scene].RemoveEvents(localID, itemID); 231 m_Dataserver[engine].RemoveEvents(localID, itemID);
226 232
227 // Remove from: Timers 233 // Remove from: Timers
228 m_Timer[scene].UnSetTimerEvents(localID, itemID); 234 m_Timer[engine].UnSetTimerEvents(localID, itemID);
229 235
230 // Remove from: HttpRequest 236 // Remove from: HttpRequest
231 IHttpRequests iHttpReq = 237 IHttpRequests iHttpReq =
232 scene.RequestModuleInterface<IHttpRequests>(); 238 engine.World.RequestModuleInterface<IHttpRequests>();
233 iHttpReq.StopHttpRequest(localID, itemID); 239 iHttpReq.StopHttpRequest(localID, itemID);
234 240
235 IWorldComm comms = scene.RequestModuleInterface<IWorldComm>(); 241 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
236 comms.DeleteListener(itemID); 242 comms.DeleteListener(itemID);
237 243
238 IXMLRPC xmlrpc = scene.RequestModuleInterface<IXMLRPC>(); 244 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
239 xmlrpc.DeleteChannels(itemID); 245 xmlrpc.DeleteChannels(itemID);
240 xmlrpc.CancelSRDRequests(itemID); 246 xmlrpc.CancelSRDRequests(itemID);
241 247
242 // Remove Sensors 248 // Remove Sensors
243 m_SensorRepeat[scene].UnSetSenseRepeaterEvents(localID, itemID); 249 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
244 250
245 } 251 }
246 252
247 public static Object[] GetSerializationData(IScene scene, UUID itemID) 253 public static Object[] GetSerializationData(IEventReceiver engine, UUID itemID)
248 { 254 {
249 List<Object> data = new List<Object>(); 255 List<Object> data = new List<Object>();
250 256
251 Object[] listeners=m_Listener[scene].GetSerializationData(itemID); 257 Object[] listeners=m_Listener[engine].GetSerializationData(itemID);
252 if (listeners.Length > 0) 258 if (listeners.Length > 0)
253 { 259 {
254 data.Add("listener"); 260 data.Add("listener");
@@ -256,7 +262,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
256 data.AddRange(listeners); 262 data.AddRange(listeners);
257 } 263 }
258 264
259 Object[] timers=m_Timer[scene].GetSerializationData(itemID); 265 Object[] timers=m_Timer[engine].GetSerializationData(itemID);
260 if (timers.Length > 0) 266 if (timers.Length > 0)
261 { 267 {
262 data.Add("timer"); 268 data.Add("timer");
@@ -264,7 +270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
264 data.AddRange(timers); 270 data.AddRange(timers);
265 } 271 }
266 272
267 Object[] sensors=m_SensorRepeat[scene].GetSerializationData(itemID); 273 Object[] sensors=m_SensorRepeat[engine].GetSerializationData(itemID);
268 if (sensors.Length > 0) 274 if (sensors.Length > 0)
269 { 275 {
270 data.Add("sensor"); 276 data.Add("sensor");
@@ -275,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
275 return data.ToArray(); 281 return data.ToArray();
276 } 282 }
277 283
278 public static void CreateFromData(IScene scene, uint localID, 284 public static void CreateFromData(IEventReceiver engine, uint localID,
279 UUID itemID, UUID hostID, Object[] data) 285 UUID itemID, UUID hostID, Object[] data)
280 { 286 {
281 int idx = 0; 287 int idx = 0;
@@ -297,15 +303,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
297 switch (type) 303 switch (type)
298 { 304 {
299 case "listener": 305 case "listener":
300 m_Listener[scene].CreateFromData(localID, itemID, 306 m_Listener[engine].CreateFromData(localID, itemID,
301 hostID, item); 307 hostID, item);
302 break; 308 break;
303 case "timer": 309 case "timer":
304 m_Timer[scene].CreateFromData(localID, itemID, 310 m_Timer[engine].CreateFromData(localID, itemID,
305 hostID, item); 311 hostID, item);
306 break; 312 break;
307 case "sensor": 313 case "sensor":
308 m_SensorRepeat[scene].CreateFromData(localID, 314 m_SensorRepeat[engine].CreateFromData(localID,
309 itemID, hostID, item); 315 itemID, hostID, item);
310 break; 316 break;
311 } 317 }