aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs')
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs74
1 files changed, 40 insertions, 34 deletions
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
index 13979ba..303bddb 100644
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
+++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
@@ -28,24 +28,23 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32using System.Threading; 31using System.Threading;
33using libsecondlife; 32using libsecondlife;
34using OpenSim.Region.ScriptEngine.Common;
35using OpenSim.Region.Environment.Modules;
36using OpenSim.Region.Environment.Interfaces; 33using OpenSim.Region.Environment.Interfaces;
34using OpenSim.Region.Environment.Modules;
37 35
38namespace OpenSim.Grid.ScriptEngine.DotNetEngine 36namespace OpenSim.Grid.ScriptEngine.DotNetEngine
39{ 37{
40 /// <summary> 38 /// <summary>
41 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. 39 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
42 /// </summary> 40 /// </summary>
43 class LSLLongCmdHandler 41 internal class LSLLongCmdHandler
44 { 42 {
45 private Thread cmdHandlerThread; 43 private Thread cmdHandlerThread;
46 private int cmdHandlerThreadCycleSleepms = 100; 44 private int cmdHandlerThreadCycleSleepms = 100;
47 45
48 private ScriptEngine m_ScriptEngine; 46 private ScriptEngine m_ScriptEngine;
47
49 public LSLLongCmdHandler(ScriptEngine _ScriptEngine) 48 public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
50 { 49 {
51 m_ScriptEngine = _ScriptEngine; 50 m_ScriptEngine = _ScriptEngine;
@@ -56,8 +55,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
56 cmdHandlerThread.Priority = ThreadPriority.BelowNormal; 55 cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
57 cmdHandlerThread.IsBackground = true; 56 cmdHandlerThread.IsBackground = true;
58 cmdHandlerThread.Start(); 57 cmdHandlerThread.Start();
59
60 } 58 }
59
61 ~LSLLongCmdHandler() 60 ~LSLLongCmdHandler()
62 { 61 {
63 // Shut down thread 62 // Shut down thread
@@ -72,7 +71,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
72 } 71 }
73 } 72 }
74 } 73 }
75 catch { } 74 catch
75 {
76 }
76 } 77 }
77 78
78 private void CmdHandlerThreadLoop() 79 private void CmdHandlerThreadLoop()
@@ -124,8 +125,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
124 public double interval; 125 public double interval;
125 public DateTime next; 126 public DateTime next;
126 } 127 }
128
127 private List<TimerClass> Timers = new List<TimerClass>(); 129 private List<TimerClass> Timers = new List<TimerClass>();
128 private object TimerListLock = new object(); 130 private object TimerListLock = new object();
131
129 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) 132 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
130 { 133 {
131 Console.WriteLine("SetTimerEvent"); 134 Console.WriteLine("SetTimerEvent");
@@ -146,6 +149,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
146 Timers.Add(ts); 149 Timers.Add(ts);
147 } 150 }
148 } 151 }
152
149 public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) 153 public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
150 { 154 {
151 // Remove from timer 155 // Remove from timer
@@ -163,6 +167,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
163 Timers = NewTimers; 167 Timers = NewTimers;
164 } 168 }
165 } 169 }
170
166 public void CheckTimerEvents() 171 public void CheckTimerEvents()
167 { 172 {
168 // Nothing to do here? 173 // Nothing to do here?
@@ -171,7 +176,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
171 176
172 lock (TimerListLock) 177 lock (TimerListLock)
173 { 178 {
174
175 // Go through all timers 179 // Go through all timers
176 foreach (TimerClass ts in Timers) 180 foreach (TimerClass ts in Timers)
177 { 181 {
@@ -179,7 +183,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
179 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) 183 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
180 { 184 {
181 // Add it to queue 185 // Add it to queue
182 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); 186 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer",
187 new object[] {});
183 // set next interval 188 // set next interval
184 189
185 190
@@ -188,6 +193,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
188 } 193 }
189 } // lock 194 } // lock
190 } 195 }
196
191 #endregion 197 #endregion
192 198
193 #region HTTP REQUEST 199 #region HTTP REQUEST
@@ -213,10 +219,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
213 { 219 {
214 // TODO: SEND REQUEST!!! 220 // TODO: SEND REQUEST!!!
215 } 221 }
222
216 public void Stop() 223 public void Stop()
217 { 224 {
218 // TODO: Cancel any ongoing request 225 // TODO: Cancel any ongoing request
219 } 226 }
227
220 public bool CheckResponse() 228 public bool CheckResponse()
221 { 229 {
222 // TODO: Check if we got a response yet, return true if so -- false if not 230 // TODO: Check if we got a response yet, return true if so -- false if not
@@ -227,11 +235,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
227 //response_status 235 //response_status
228 //response_metadata 236 //response_metadata
229 //response_body 237 //response_body
230
231 } 238 }
232 } 239 }
240
233 private List<HttpClass> HttpRequests = new List<HttpClass>(); 241 private List<HttpClass> HttpRequests = new List<HttpClass>();
234 private object HttpListLock = new object(); 242 private object HttpListLock = new object();
243
235 public void StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body) 244 public void StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body)
236 { 245 {
237 Console.WriteLine("StartHttpRequest"); 246 Console.WriteLine("StartHttpRequest");
@@ -244,11 +253,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
244 htc.body = body; 253 htc.body = body;
245 lock (HttpListLock) 254 lock (HttpListLock)
246 { 255 {
247
248 //ADD REQUEST 256 //ADD REQUEST
249 HttpRequests.Add(htc); 257 HttpRequests.Add(htc);
250 } 258 }
251 } 259 }
260
252 public void StopHttpRequest(uint m_localID, LLUUID m_itemID) 261 public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
253 { 262 {
254 // Remove from list 263 // Remove from list
@@ -272,6 +281,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
272 HttpRequests = NewHttpList; 281 HttpRequests = NewHttpList;
273 } 282 }
274 } 283 }
284
275 public void CheckHttpRequests() 285 public void CheckHttpRequests()
276 { 286 {
277 // Nothing to do here? 287 // Nothing to do here?
@@ -282,68 +292,64 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
282 { 292 {
283 foreach (HttpClass ts in HttpRequests) 293 foreach (HttpClass ts in HttpRequests)
284 { 294 {
285
286 if (ts.CheckResponse() == true) 295 if (ts.CheckResponse() == true)
287 { 296 {
288 // Add it to event queue 297 // Add it to event queue
289 //key request_id, integer status, list metadata, string body 298 //key request_id, integer status, list metadata, string body
290 object[] resobj = new object[] { ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body }; 299 object[] resobj =
291 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", resobj); 300 new object[]
301 {ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body};
302 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response",
303 resobj);
292 // Now stop it 304 // Now stop it
293 StopHttpRequest(ts.localID, ts.itemID); 305 StopHttpRequest(ts.localID, ts.itemID);
294 } 306 }
295 } 307 }
296 } // lock 308 } // lock
297 } 309 }
310
298 #endregion 311 #endregion
299 312
300 public void CheckXMLRPCRequests() 313 public void CheckXMLRPCRequests()
301 { 314 {
302
303 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 315 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
304 316
305 while (xmlrpc.hasRequests()) 317 while (xmlrpc.hasRequests())
306 { 318 {
307 RPCRequestInfo rInfo = xmlrpc.GetNextRequest(); 319 RPCRequestInfo rInfo = xmlrpc.GetNextRequest();
308 System.Console.WriteLine("PICKED REQUEST"); 320 Console.WriteLine("PICKED REQUEST");
309 321
310 //Deliver data to prim's remote_data handler 322 //Deliver data to prim's remote_data handler
311 object[] resobj = new object[] { 323 object[] resobj = new object[]
312 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), rInfo.GetStrVal() 324 {
313 }; 325 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(),
326 rInfo.GetStrVal()
327 };
314 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 328 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
315 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj 329 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj
316 ); 330 );
317
318 } 331 }
319
320 } 332 }
321 333
322 public void CheckListeners() 334 public void CheckListeners()
323 { 335 {
324
325 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 336 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
326 337
327 while (comms.HasMessages()) 338 while (comms.HasMessages())
328 { 339 {
329 ListenerInfo lInfo = comms.GetNextMessage(); 340 ListenerInfo lInfo = comms.GetNextMessage();
330 System.Console.WriteLine("PICKED LISTENER"); 341 Console.WriteLine("PICKED LISTENER");
331 342
332 //Deliver data to prim's listen handler 343 //Deliver data to prim's listen handler
333 object[] resobj = new object[] { 344 object[] resobj = new object[]
334 lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() 345 {
335 }; 346 lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
347 };
336 348
337 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 349 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
338 lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj 350 lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj
339 ); 351 );
340
341 } 352 }
342
343 } 353 }
344
345
346
347
348 } 354 }
349} 355} \ No newline at end of file