aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-02-25 19:45:34 +0000
committerTedd Hansen2008-02-25 19:45:34 +0000
commitce9c74a83c442119692ec0477555a3253374e427 (patch)
tree31ed159765e18b7e5c2a41a4262a1332ef8bc76c /OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
parentInitial patch for llSensor* (diff)
downloadopensim-SC_OLD-ce9c74a83c442119692ec0477555a3253374e427.zip
opensim-SC_OLD-ce9c74a83c442119692ec0477555a3253374e427.tar.gz
opensim-SC_OLD-ce9c74a83c442119692ec0477555a3253374e427.tar.bz2
opensim-SC_OLD-ce9c74a83c442119692ec0477555a3253374e427.tar.xz
Step 1 in reorganizing AsyncCommandManager
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs677
1 files changed, 677 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
new file mode 100644
index 0000000..1133a8e
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
@@ -0,0 +1,677 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Threading;
33using libsecondlife;
34using Axiom.Math;
35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Modules;
37using OpenSim.Region.Environment.Scenes;
38using OpenSim.Framework;
39
40namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
41{
42 /// <summary>
43 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
44 /// </summary>
45 public class AsyncCommandManager : iScriptEngineFunctionModule
46 {
47 private static Thread cmdHandlerThread;
48 private static int cmdHandlerThreadCycleSleepms;
49
50 private ScriptEngine m_ScriptEngine;
51
52 public Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>> SenseEvents =
53 new Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>>();
54 private Object SenseLock = new Object();
55
56 public AsyncCommandManager(ScriptEngine _ScriptEngine)
57 {
58 m_ScriptEngine = _ScriptEngine;
59 ReadConfig();
60
61 StartThread();
62 }
63
64 private void StartThread()
65 {
66 if (cmdHandlerThread == null)
67 {
68 // Start the thread that will be doing the work
69 cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
70 cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
71 cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
72 cmdHandlerThread.IsBackground = true;
73 cmdHandlerThread.Start();
74 OpenSim.Framework.ThreadTracker.Add(cmdHandlerThread);
75 }
76 }
77
78 public void ReadConfig()
79 {
80 cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100);
81 }
82
83 ~AsyncCommandManager()
84 {
85 // Shut down thread
86 try
87 {
88 if (cmdHandlerThread != null)
89 {
90 if (cmdHandlerThread.IsAlive == true)
91 {
92 cmdHandlerThread.Abort();
93 //cmdHandlerThread.Join();
94 }
95 }
96 }
97 catch
98 {
99 }
100 }
101
102 private static void CmdHandlerThreadLoop()
103 {
104 while (true)
105 {
106 try
107 {
108 while (true)
109 {
110 Thread.Sleep(cmdHandlerThreadCycleSleepms);
111 //lock (ScriptEngine.ScriptEngines)
112 //{
113 foreach (ScriptEngine se in new ArrayList(ScriptEngine.ScriptEngines))
114 {
115 se.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass();
116 }
117 //}
118 // Sleep before next cycle
119 //Thread.Sleep(cmdHandlerThreadCycleSleepms);
120 }
121 }
122 catch
123 {
124 }
125 }
126 }
127
128 internal void DoOneCmdHandlerPass()
129 {
130 // Check timers
131 CheckTimerEvents();
132 // Check HttpRequests
133 CheckHttpRequests();
134 // Check XMLRPCRequests
135 CheckXMLRPCRequests();
136 // Check Listeners
137 CheckListeners();
138 // Check Sensors
139 CheckSenseRepeaterEvents();
140 }
141
142 /// <summary>
143 /// Remove a specific script (and all its pending commands)
144 /// </summary>
145 /// <param name="localID"></param>
146 /// <param name="itemID"></param>
147 public void RemoveScript(uint localID, LLUUID itemID)
148 {
149 // Remove a specific script
150
151 // Remove from: Timers
152 UnSetTimerEvents(localID, itemID);
153 // Remove from: HttpRequest
154 IHttpRequests iHttpReq =
155 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
156 iHttpReq.StopHttpRequest(localID, itemID);
157
158 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
159 comms.DeleteListener(itemID);
160
161 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
162 xmlrpc.DeleteChannels(itemID);
163
164 xmlrpc.CancelSRDRequests(itemID);
165
166 // Remove Sensors
167 UnSetSenseRepeaterEvents(localID, itemID);
168
169 }
170
171 #region TIMER
172
173 //
174 // TIMER
175 //
176 private class TimerClass
177 {
178 public uint localID;
179 public LLUUID itemID;
180 //public double interval;
181 public long interval;
182 //public DateTime next;
183 public long next;
184 }
185
186 private List<TimerClass> Timers = new List<TimerClass>();
187 private object TimerListLock = new object();
188
189 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
190 {
191 Console.WriteLine("SetTimerEvent");
192
193 // Always remove first, in case this is a re-set
194 UnSetTimerEvents(m_localID, m_itemID);
195 if (sec == 0) // Disabling timer
196 return;
197
198 // Add to timer
199 TimerClass ts = new TimerClass();
200 ts.localID = m_localID;
201 ts.itemID = m_itemID;
202 ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait
203 // 2193386136332921 ticks
204 // 219338613 seconds
205
206 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
207 ts.next = DateTime.Now.Ticks + ts.interval;
208 lock (TimerListLock)
209 {
210 Timers.Add(ts);
211 }
212 }
213
214 public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
215 {
216 // Remove from timer
217 lock (TimerListLock)
218 {
219 foreach (TimerClass ts in new ArrayList(Timers))
220 {
221 if (ts.localID == m_localID && ts.itemID == m_itemID)
222 Timers.Remove(ts);
223 }
224 }
225
226 // Old method: Create new list
227 //List<TimerClass> NewTimers = new List<TimerClass>();
228 //foreach (TimerClass ts in Timers)
229 //{
230 // if (ts.localID != m_localID && ts.itemID != m_itemID)
231 // {
232 // NewTimers.Add(ts);
233 // }
234 //}
235 //Timers.Clear();
236 //Timers = NewTimers;
237 //}
238 }
239
240 public void CheckTimerEvents()
241 {
242 // Nothing to do here?
243 if (Timers.Count == 0)
244 return;
245
246 lock (TimerListLock)
247 {
248 // Go through all timers
249 foreach (TimerClass ts in Timers)
250 {
251 // Time has passed?
252 if (ts.next < DateTime.Now.Ticks)
253 {
254// Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
255 // Add it to queue
256 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull,
257 null);
258 // set next interval
259
260 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
261 ts.next = DateTime.Now.Ticks + ts.interval;
262 }
263 }
264 }
265 }
266
267 #endregion
268 #region SENSOR
269
270 //
271 // SenseRepeater and Sensors
272 //
273 private class SenseRepeatClass
274 {
275 public uint localID;
276 public LLUUID itemID;
277 public double interval;
278 public DateTime next;
279
280 public string name;
281 public LLUUID keyID;
282 public int type;
283 public double range;
284 public double arc;
285 public SceneObjectPart host;
286 }
287
288 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
289 private object SenseRepeatListLock = new object();
290
291 public void SetSenseRepeatEvent(uint m_localID, LLUUID m_itemID,
292 string name, LLUUID keyID, int type, double range, double arc, double sec,SceneObjectPart host)
293 {
294 Console.WriteLine("SetSensorEvent");
295
296 // Always remove first, in case this is a re-set
297 UnSetSenseRepeaterEvents(m_localID, m_itemID);
298 if (sec == 0) // Disabling timer
299 return;
300
301 // Add to timer
302 SenseRepeatClass ts = new SenseRepeatClass();
303 ts.localID = m_localID;
304 ts.itemID = m_itemID;
305 ts.interval = sec;
306 ts.name = name;
307 ts.keyID = keyID;
308 ts.type = type;
309 ts.range = range;
310 ts.arc = arc;
311 ts.host = host;
312
313 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
314 lock (SenseRepeatListLock)
315 {
316 SenseRepeaters.Add(ts);
317 }
318 }
319
320 public void UnSetSenseRepeaterEvents(uint m_localID, LLUUID m_itemID)
321 {
322 // Remove from timer
323 lock (SenseRepeatListLock)
324 {
325 List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>();
326 foreach (SenseRepeatClass ts in SenseRepeaters)
327 {
328 if (ts.localID != m_localID && ts.itemID != m_itemID)
329 {
330 NewSensors.Add(ts);
331 }
332 }
333 SenseRepeaters.Clear();
334 SenseRepeaters = NewSensors;
335 }
336 }
337
338 public void CheckSenseRepeaterEvents()
339 {
340 // Nothing to do here?
341 if (SenseRepeaters.Count == 0)
342 return;
343
344 lock (SenseRepeatListLock)
345 {
346 // Go through all timers
347 foreach (SenseRepeatClass ts in SenseRepeaters)
348 {
349 // Time has passed?
350 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
351 {
352 SensorSweep(ts);
353 // set next interval
354 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
355 }
356 }
357 } // lock
358 }
359
360 public void SenseOnce(uint m_localID, LLUUID m_itemID,
361 string name, LLUUID keyID, int type, double range, double arc, SceneObjectPart host)
362 {
363 // Add to timer
364 SenseRepeatClass ts = new SenseRepeatClass();
365 ts.localID = m_localID;
366 ts.itemID = m_itemID;
367 ts.interval = 0;
368 ts.name = name;
369 ts.keyID = keyID;
370 ts.type = type;
371 ts.range = range;
372 ts.arc = arc;
373 ts.host = host;
374 SensorSweep(ts);
375 }
376
377 public LSL_Types.list GetSensorList(uint m_localID, LLUUID m_itemID)
378 {
379 lock (SenseLock)
380 {
381 Dictionary<LLUUID, LSL_Types.list> Obj = null;
382 if (!SenseEvents.TryGetValue(m_localID, out Obj))
383 {
384 m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID);
385 return null;
386 }
387 lock (Obj)
388 {
389 // Get script
390 LSL_Types.list SenseList = null;
391 if (!Obj.TryGetValue(m_itemID, out SenseList))
392 {
393 m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID);
394 return null;
395 }
396 return SenseList;
397 }
398 }
399
400 }
401
402 private void SensorSweep(SenseRepeatClass ts)
403 {
404 //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep");
405 SceneObjectPart SensePoint =ts.host;
406
407 if (SensePoint == null)
408 {
409 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString());
410 return;
411 }
412 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan");
413
414 LLVector3 sensorPos = SensePoint.AbsolutePosition;
415 LLVector3 regionPos = new LLVector3(m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
416 LLVector3 fromRegionPos = sensorPos + regionPos;
417
418 LLQuaternion q = SensePoint.RotationOffset;
419 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
420 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
421 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
422
423 // Here we should do some smart culling ...
424 // math seems quicker than strings so try that first
425 LSL_Types.list SensedObjects = new LSL_Types.list();
426 LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0);
427
428 foreach (EntityBase ent in m_ScriptEngine.World.Entities.Values)
429 {
430
431 LLVector3 toRegionPos = ent.AbsolutePosition + regionPos;
432 double dis = Math.Abs((double) Util.GetDistanceTo(toRegionPos, fromRegionPos));
433 if (dis <= ts.range)
434 {
435 // In Range, is it the right Type ?
436 int objtype = 0;
437
438 if (m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor
439 if (ent.Velocity.Equals(ZeroVector))
440 objtype |= 0x04; // passive non-moving
441 else
442 objtype |= 0x02; // active moving
443 if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ...
444
445 if ( ((ts.type & objtype) != 0 ) ||((ts.type & objtype) == ts.type ))
446 {
447 // docs claim AGENT|ACTIVE should find agent objects OR active objects
448 // so the bitwise AND with object type should be non-zero
449
450 // Right type too, what about the other params , key and name ?
451 bool keep = true;
452 if (ts.arc != Math.PI)
453 {
454 // not omni-directional. Can you see it ?
455 // vec forward_dir = llRot2Fwd(llGetRot())
456 // vec obj_dir = toRegionPos-fromRegionPos
457 // dot=dot(forward_dir,obj_dir)
458 // mag_fwd = mag(forward_dir)
459 // mag_obj = mag(obj_dir)
460 // ang = acos( dot /(mag_fwd*mag_obj))
461 double ang_obj = 0;
462 try
463 {
464 LLVector3 diff =toRegionPos - fromRegionPos;
465 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
466 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
467 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
468 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
469 }
470 catch
471 {
472 }
473
474 if (ang_obj > ts.arc) keep = false;
475 }
476
477 if (keep && (ts.name.Length > 0) && (ts.name != ent.Name))
478 {
479 keep = false;
480 }
481
482 if (keep && (ts.keyID != null) && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID))
483 {
484 keep = false;
485 }
486 if (keep==true) SensedObjects.Add(ent.UUID);
487 }
488 }
489 }
490 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock");
491
492 lock (SenseLock)
493 {
494 // Create object if it doesn't exist
495 if (SenseEvents.ContainsKey(ts.localID) == false)
496 {
497 SenseEvents.Add(ts.localID, new Dictionary<LLUUID, LSL_Types.list>());
498 }
499 // clear if previous traces exist
500 Dictionary<LLUUID, LSL_Types.list> Obj;
501 SenseEvents.TryGetValue(ts.localID, out Obj);
502 if (Obj.ContainsKey(ts.itemID) == true)
503 Obj.Remove(ts.itemID);
504
505 // note list may be zero length
506 Obj.Add(ts.itemID, SensedObjects);
507
508 if (SensedObjects.Length == 0)
509 {
510 // send a "no_sensor"
511 // Add it to queue
512 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "no_sensor", EventQueueManager.llDetectNull,
513 new object[] {});
514 }
515 else
516 {
517
518 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull,
519 new object[] { SensedObjects.Length });
520 }
521 }
522 }
523 #endregion
524
525 #region HTTP REQUEST
526
527 public void CheckHttpRequests()
528 {
529 if (m_ScriptEngine.World == null)
530 return;
531
532 IHttpRequests iHttpReq =
533 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
534
535 HttpRequestClass httpInfo = null;
536
537 if (iHttpReq != null)
538 httpInfo = iHttpReq.GetNextCompletedRequest();
539
540 while (httpInfo != null)
541 {
542 //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
543
544 // Deliver data to prim's remote_data handler
545 //
546 // TODO: Returning null for metadata, since the lsl function
547 // only returns the byte for HTTP_BODY_TRUNCATED, which is not
548 // implemented here yet anyway. Should be fixed if/when maxsize
549 // is supported
550
551 if (m_ScriptEngine.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null)
552 {
553 iHttpReq.RemoveCompletedRequest(httpInfo.reqID);
554 object[] resobj = new object[]
555 {
556 httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body
557 };
558
559 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
560 httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj
561 );
562 //Thread.Sleep(2500);
563 }
564
565 httpInfo = iHttpReq.GetNextCompletedRequest();
566 }
567 }
568
569 #endregion
570
571 #region Check llRemoteData channels
572
573 public void CheckXMLRPCRequests()
574 {
575 if (m_ScriptEngine.World == null)
576 return;
577
578 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
579
580 if (xmlrpc != null)
581 {
582 RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest();
583
584 while (rInfo != null)
585 {
586 if (m_ScriptEngine.m_ScriptManager.GetScript(rInfo.GetLocalID(), rInfo.GetItemID()) != null)
587 {
588 xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID());
589
590 //Deliver data to prim's remote_data handler
591 object[] resobj = new object[]
592 {
593 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), String.Empty,
594 rInfo.GetIntValue(),
595 rInfo.GetStrVal()
596 };
597 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
598 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj
599 );
600 }
601
602 rInfo = xmlrpc.GetNextCompletedRequest();
603 }
604
605 SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest();
606
607 while (srdInfo != null)
608 {
609 if (m_ScriptEngine.m_ScriptManager.GetScript(srdInfo.m_localID, srdInfo.m_itemID) != null)
610 {
611 xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID());
612
613 //Deliver data to prim's remote_data handler
614 object[] resobj = new object[]
615 {
616 3, srdInfo.channel.ToString(), srdInfo.GetReqID().ToString(), String.Empty,
617 srdInfo.idata,
618 srdInfo.sdata
619 };
620 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
621 srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj
622 );
623 }
624
625 srdInfo = xmlrpc.GetNextCompletedSRDRequest();
626 }
627 }
628 }
629
630 #endregion
631
632 #region Check llListeners
633
634 public void CheckListeners()
635 {
636 if (m_ScriptEngine.World == null)
637 return;
638 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
639
640 if (comms != null)
641 {
642 while (comms.HasMessages())
643 {
644 if (m_ScriptEngine.m_ScriptManager.GetScript(
645 comms.PeekNextMessageLocalID(), comms.PeekNextMessageItemID()) != null)
646 {
647 ListenerInfo lInfo = comms.GetNextMessage();
648
649 //Deliver data to prim's listen handler
650 object[] resobj = new object[]
651 {
652 //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
653 lInfo.GetChannel(), lInfo.GetName(), lInfo.GetSourceItemID().ToString(), lInfo.GetMessage()
654 };
655
656 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
657 lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj
658 );
659 }
660 }
661 }
662 }
663
664 #endregion
665
666 /// <summary>
667 /// If set to true then threads and stuff should try to make a graceful exit
668 /// </summary>
669 public bool PleaseShutdown
670 {
671 get { return _PleaseShutdown; }
672 set { _PleaseShutdown = value; }
673 }
674 private bool _PleaseShutdown = false;
675
676 }
677}