diff options
author | Tedd Hansen | 2008-02-25 20:10:17 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-02-25 20:10:17 +0000 |
commit | dbb205c18160cfe031e4076ac650eb37b9613b86 (patch) | |
tree | 0b2202ddbc710755e807bed06a0e84a795ca2e20 /OpenSim/Region | |
parent | eol (diff) | |
download | opensim-SC_OLD-dbb205c18160cfe031e4076ac650eb37b9613b86.zip opensim-SC_OLD-dbb205c18160cfe031e4076ac650eb37b9613b86.tar.gz opensim-SC_OLD-dbb205c18160cfe031e4076ac650eb37b9613b86.tar.bz2 opensim-SC_OLD-dbb205c18160cfe031e4076ac650eb37b9613b86.tar.xz |
Moved AsyncCommandManager into separate classes under "plugins".
Diffstat (limited to '')
7 files changed, 744 insertions, 519 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index f9bcc06..7d4219b 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -371,7 +371,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
371 | catch | 371 | catch |
372 | { | 372 | { |
373 | } | 373 | } |
374 | m_ScriptEngine.m_ASYNCLSLCommandManager.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); | 374 | m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); |
375 | 375 | ||
376 | return; | 376 | return; |
377 | // NotImplemented("llSensor"); | 377 | // NotImplemented("llSensor"); |
@@ -389,7 +389,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
389 | { | 389 | { |
390 | } | 390 | } |
391 | 391 | ||
392 | m_ScriptEngine.m_ASYNCLSLCommandManager.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); | 392 | m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); |
393 | return; | 393 | return; |
394 | // NotImplemented("llSensorRepeat"); | 394 | // NotImplemented("llSensorRepeat"); |
395 | } | 395 | } |
@@ -397,7 +397,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
397 | public void llSensorRemove() | 397 | public void llSensorRemove() |
398 | { | 398 | { |
399 | m_host.AddScriptLPS(1); | 399 | m_host.AddScriptLPS(1); |
400 | m_ScriptEngine.m_ASYNCLSLCommandManager.UnSetSenseRepeaterEvents(m_localID, m_itemID); | 400 | m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.UnSetSenseRepeaterEvents(m_localID, m_itemID); |
401 | return; | 401 | return; |
402 | // NotImplemented("llSensorRemove"); | 402 | // NotImplemented("llSensorRemove"); |
403 | } | 403 | } |
@@ -405,7 +405,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
405 | public string llDetectedName(int number) | 405 | public string llDetectedName(int number) |
406 | { | 406 | { |
407 | m_host.AddScriptLPS(1); | 407 | m_host.AddScriptLPS(1); |
408 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.GetSensorList(m_localID, m_itemID); | 408 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); |
409 | if ((number>0)&&(number <= SenseList.Length)) | 409 | if ((number>0)&&(number <= SenseList.Length)) |
410 | { | 410 | { |
411 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; | 411 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; |
@@ -427,7 +427,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
427 | 427 | ||
428 | public LLUUID uuidDetectedKey(int number) | 428 | public LLUUID uuidDetectedKey(int number) |
429 | { | 429 | { |
430 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.GetSensorList(m_localID, m_itemID); | 430 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); |
431 | if ((number >= 0) && (number < SenseList.Length)) | 431 | if ((number >= 0) && (number < SenseList.Length)) |
432 | { | 432 | { |
433 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; | 433 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; |
@@ -438,7 +438,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
438 | 438 | ||
439 | public EntityBase entityDetectedKey(int number) | 439 | public EntityBase entityDetectedKey(int number) |
440 | { | 440 | { |
441 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.GetSensorList(m_localID, m_itemID); | 441 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); |
442 | if ((number >= 0) && (number < SenseList.Length)) | 442 | if ((number >= 0) && (number < SenseList.Length)) |
443 | { | 443 | { |
444 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; | 444 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; |
@@ -1347,7 +1347,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
1347 | { | 1347 | { |
1348 | m_host.AddScriptLPS(1); | 1348 | m_host.AddScriptLPS(1); |
1349 | // Setting timer repeat | 1349 | // Setting timer repeat |
1350 | m_ScriptEngine.m_ASYNCLSLCommandManager.SetTimerEvent(m_localID, m_itemID, sec); | 1350 | m_ScriptEngine.m_ASYNCLSLCommandManager.m_Timer.SetTimerEvent(m_localID, m_itemID, sec); |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | public void llSleep(double sec) | 1353 | public void llSleep(double sec) |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs index e9539e6..0555d61 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs | |||
@@ -36,6 +36,8 @@ using OpenSim.Region.Environment.Interfaces; | |||
36 | using OpenSim.Region.Environment.Modules; | 36 | using OpenSim.Region.Environment.Modules; |
37 | using OpenSim.Region.Environment.Scenes; | 37 | using OpenSim.Region.Environment.Scenes; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; | ||
40 | using Timer=OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins.Timer; | ||
39 | 41 | ||
40 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | 42 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase |
41 | { | 43 | { |
@@ -47,17 +49,26 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
47 | private static Thread cmdHandlerThread; | 49 | private static Thread cmdHandlerThread; |
48 | private static int cmdHandlerThreadCycleSleepms; | 50 | private static int cmdHandlerThreadCycleSleepms; |
49 | 51 | ||
50 | private ScriptEngine m_ScriptEngine; | 52 | public ScriptEngine m_ScriptEngine; |
51 | 53 | ||
52 | public Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>> SenseEvents = | 54 | public AsyncCommandPlugins.Timer m_Timer; |
53 | new Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>>(); | 55 | public AsyncCommandPlugins.HttpRequest m_HttpRequest; |
54 | private Object SenseLock = new Object(); | 56 | public AsyncCommandPlugins.Listener m_Listener; |
57 | public AsyncCommandPlugins.SensorRepeat m_SensorRepeat; | ||
58 | public AsyncCommandPlugins.XmlRequest m_XmlRequest; | ||
55 | 59 | ||
56 | public AsyncCommandManager(ScriptEngine _ScriptEngine) | 60 | public AsyncCommandManager(ScriptEngine _ScriptEngine) |
57 | { | 61 | { |
58 | m_ScriptEngine = _ScriptEngine; | 62 | m_ScriptEngine = _ScriptEngine; |
59 | ReadConfig(); | 63 | ReadConfig(); |
60 | 64 | ||
65 | // Create instances of all plugins | ||
66 | m_Timer = new Timer(this); | ||
67 | m_HttpRequest = new HttpRequest(this); | ||
68 | m_Listener = new Listener(this); | ||
69 | m_SensorRepeat = new SensorRepeat(this); | ||
70 | m_XmlRequest = new XmlRequest(this); | ||
71 | |||
61 | StartThread(); | 72 | StartThread(); |
62 | } | 73 | } |
63 | 74 | ||
@@ -128,15 +139,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
128 | internal void DoOneCmdHandlerPass() | 139 | internal void DoOneCmdHandlerPass() |
129 | { | 140 | { |
130 | // Check timers | 141 | // Check timers |
131 | CheckTimerEvents(); | 142 | m_Timer.CheckTimerEvents(); |
132 | // Check HttpRequests | 143 | // Check HttpRequests |
133 | CheckHttpRequests(); | 144 | m_HttpRequest.CheckHttpRequests(); |
134 | // Check XMLRPCRequests | 145 | // Check XMLRPCRequests |
135 | CheckXMLRPCRequests(); | 146 | m_XmlRequest.CheckXMLRPCRequests(); |
136 | // Check Listeners | 147 | // Check Listeners |
137 | CheckListeners(); | 148 | m_Listener.CheckListeners(); |
138 | // Check Sensors | 149 | // Check Sensors |
139 | CheckSenseRepeaterEvents(); | 150 | m_SensorRepeat.CheckSenseRepeaterEvents(); |
140 | } | 151 | } |
141 | 152 | ||
142 | /// <summary> | 153 | /// <summary> |
@@ -149,7 +160,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
149 | // Remove a specific script | 160 | // Remove a specific script |
150 | 161 | ||
151 | // Remove from: Timers | 162 | // Remove from: Timers |
152 | UnSetTimerEvents(localID, itemID); | 163 | m_Timer.UnSetTimerEvents(localID, itemID); |
164 | |||
153 | // Remove from: HttpRequest | 165 | // Remove from: HttpRequest |
154 | IHttpRequests iHttpReq = | 166 | IHttpRequests iHttpReq = |
155 | m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); | 167 | m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); |
@@ -160,506 +172,21 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
160 | 172 | ||
161 | IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | 173 | IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); |
162 | xmlrpc.DeleteChannels(itemID); | 174 | xmlrpc.DeleteChannels(itemID); |
163 | |||
164 | xmlrpc.CancelSRDRequests(itemID); | 175 | xmlrpc.CancelSRDRequests(itemID); |
165 | 176 | ||
166 | // Remove Sensors | 177 | // Remove Sensors |
167 | UnSetSenseRepeaterEvents(localID, itemID); | 178 | m_SensorRepeat.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 | 179 | ||
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 | } | 180 | } |
523 | #endregion | ||
524 | |||
525 | #region HTTP REQUEST | ||
526 | |||
527 | public void CheckHttpRequests() | ||
528 | { | ||
529 | if (m_ScriptEngine.World == null) | ||
530 | return; | ||
531 | 181 | ||
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 | 182 | ||
571 | #region Check llRemoteData channels | 183 | #region Check llRemoteData channels |
572 | 184 | ||
573 | public void CheckXMLRPCRequests() | 185 | |
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 | 186 | #endregion |
631 | 187 | ||
632 | #region Check llListeners | 188 | #region Check llListeners |
633 | 189 | ||
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 | 190 | ||
664 | #endregion | 191 | #endregion |
665 | 192 | ||
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs index c9214f1..94c536f 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs | |||
@@ -1,10 +1,97 @@ | |||
1 | using System; | 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 | |||
29 | using System; | ||
30 | using System.Collections; | ||
2 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
3 | using System.Text; | 32 | using System.Threading; |
33 | using libsecondlife; | ||
34 | using Axiom.Math; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; | ||
4 | 40 | ||
5 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins | 41 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins |
6 | { | 42 | { |
7 | class HttpRequest | 43 | public class HttpRequest |
8 | { | 44 | { |
45 | public AsyncCommandManager m_CmdManager; | ||
46 | |||
47 | public HttpRequest(AsyncCommandManager CmdManager) | ||
48 | { | ||
49 | m_CmdManager = CmdManager; | ||
50 | } | ||
51 | |||
52 | |||
53 | public void CheckHttpRequests() | ||
54 | { | ||
55 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
56 | return; | ||
57 | |||
58 | IHttpRequests iHttpReq = | ||
59 | m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); | ||
60 | |||
61 | HttpRequestClass httpInfo = null; | ||
62 | |||
63 | if (iHttpReq != null) | ||
64 | httpInfo = iHttpReq.GetNextCompletedRequest(); | ||
65 | |||
66 | while (httpInfo != null) | ||
67 | { | ||
68 | //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status); | ||
69 | |||
70 | // Deliver data to prim's remote_data handler | ||
71 | // | ||
72 | // TODO: Returning null for metadata, since the lsl function | ||
73 | // only returns the byte for HTTP_BODY_TRUNCATED, which is not | ||
74 | // implemented here yet anyway. Should be fixed if/when maxsize | ||
75 | // is supported | ||
76 | |||
77 | if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null) | ||
78 | { | ||
79 | iHttpReq.RemoveCompletedRequest(httpInfo.reqID); | ||
80 | object[] resobj = new object[] | ||
81 | { | ||
82 | httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body | ||
83 | }; | ||
84 | |||
85 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( | ||
86 | httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj | ||
87 | ); | ||
88 | //Thread.Sleep(2500); | ||
89 | } | ||
90 | |||
91 | httpInfo = iHttpReq.GetNextCompletedRequest(); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
9 | } | 96 | } |
10 | } | 97 | } |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs index f677649..194cb6b2 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs | |||
@@ -1,10 +1,83 @@ | |||
1 | using System; | 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 | |||
29 | using System; | ||
30 | using System.Collections; | ||
2 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
3 | using System.Text; | 32 | using System.Threading; |
33 | using libsecondlife; | ||
34 | using Axiom.Math; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; | ||
4 | 40 | ||
5 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins | 41 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins |
6 | { | 42 | { |
7 | class Listener | 43 | public class Listener |
8 | { | 44 | { |
45 | public AsyncCommandManager m_CmdManager; | ||
46 | |||
47 | public Listener(AsyncCommandManager CmdManager) | ||
48 | { | ||
49 | m_CmdManager = CmdManager; | ||
50 | } | ||
51 | |||
52 | |||
53 | public void CheckListeners() | ||
54 | { | ||
55 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
56 | return; | ||
57 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
58 | |||
59 | if (comms != null) | ||
60 | { | ||
61 | while (comms.HasMessages()) | ||
62 | { | ||
63 | if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript( | ||
64 | comms.PeekNextMessageLocalID(), comms.PeekNextMessageItemID()) != null) | ||
65 | { | ||
66 | ListenerInfo lInfo = comms.GetNextMessage(); | ||
67 | |||
68 | //Deliver data to prim's listen handler | ||
69 | object[] resobj = new object[] | ||
70 | { | ||
71 | //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() | ||
72 | lInfo.GetChannel(), lInfo.GetName(), lInfo.GetSourceItemID().ToString(), lInfo.GetMessage() | ||
73 | }; | ||
74 | |||
75 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( | ||
76 | lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj | ||
77 | ); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | } | ||
9 | } | 82 | } |
10 | } | 83 | } |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs index 3324bdf..edf3fde 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs | |||
@@ -1,10 +1,311 @@ | |||
1 | using System; | 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 | |||
29 | using System; | ||
30 | using System.Collections; | ||
2 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
3 | using System.Text; | 32 | using System.Threading; |
33 | using libsecondlife; | ||
34 | using Axiom.Math; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; | ||
4 | 40 | ||
5 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins | 41 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins |
6 | { | 42 | { |
7 | class SensorRepeat | 43 | public class SensorRepeat |
8 | { | 44 | { |
45 | public AsyncCommandManager m_CmdManager; | ||
46 | |||
47 | public SensorRepeat(AsyncCommandManager CmdManager) | ||
48 | { | ||
49 | m_CmdManager = CmdManager; | ||
50 | } | ||
51 | |||
52 | |||
53 | public Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>> SenseEvents = | ||
54 | new Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>>(); | ||
55 | private Object SenseLock = new Object(); | ||
56 | |||
57 | // | ||
58 | // SenseRepeater and Sensors | ||
59 | // | ||
60 | private class SenseRepeatClass | ||
61 | { | ||
62 | public uint localID; | ||
63 | public LLUUID itemID; | ||
64 | public double interval; | ||
65 | public DateTime next; | ||
66 | |||
67 | public string name; | ||
68 | public LLUUID keyID; | ||
69 | public int type; | ||
70 | public double range; | ||
71 | public double arc; | ||
72 | public SceneObjectPart host; | ||
73 | } | ||
74 | |||
75 | private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>(); | ||
76 | private object SenseRepeatListLock = new object(); | ||
77 | |||
78 | public void SetSenseRepeatEvent(uint m_localID, LLUUID m_itemID, | ||
79 | string name, LLUUID keyID, int type, double range, double arc, double sec, SceneObjectPart host) | ||
80 | { | ||
81 | Console.WriteLine("SetSensorEvent"); | ||
82 | |||
83 | // Always remove first, in case this is a re-set | ||
84 | UnSetSenseRepeaterEvents(m_localID, m_itemID); | ||
85 | if (sec == 0) // Disabling timer | ||
86 | return; | ||
87 | |||
88 | // Add to timer | ||
89 | SenseRepeatClass ts = new SenseRepeatClass(); | ||
90 | ts.localID = m_localID; | ||
91 | ts.itemID = m_itemID; | ||
92 | ts.interval = sec; | ||
93 | ts.name = name; | ||
94 | ts.keyID = keyID; | ||
95 | ts.type = type; | ||
96 | ts.range = range; | ||
97 | ts.arc = arc; | ||
98 | ts.host = host; | ||
99 | |||
100 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
101 | lock (SenseRepeatListLock) | ||
102 | { | ||
103 | SenseRepeaters.Add(ts); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public void UnSetSenseRepeaterEvents(uint m_localID, LLUUID m_itemID) | ||
108 | { | ||
109 | // Remove from timer | ||
110 | lock (SenseRepeatListLock) | ||
111 | { | ||
112 | List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>(); | ||
113 | foreach (SenseRepeatClass ts in SenseRepeaters) | ||
114 | { | ||
115 | if (ts.localID != m_localID && ts.itemID != m_itemID) | ||
116 | { | ||
117 | NewSensors.Add(ts); | ||
118 | } | ||
119 | } | ||
120 | SenseRepeaters.Clear(); | ||
121 | SenseRepeaters = NewSensors; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | public void CheckSenseRepeaterEvents() | ||
126 | { | ||
127 | // Nothing to do here? | ||
128 | if (SenseRepeaters.Count == 0) | ||
129 | return; | ||
130 | |||
131 | lock (SenseRepeatListLock) | ||
132 | { | ||
133 | // Go through all timers | ||
134 | foreach (SenseRepeatClass ts in SenseRepeaters) | ||
135 | { | ||
136 | // Time has passed? | ||
137 | if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) | ||
138 | { | ||
139 | SensorSweep(ts); | ||
140 | // set next interval | ||
141 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
142 | } | ||
143 | } | ||
144 | } // lock | ||
145 | } | ||
146 | |||
147 | public void SenseOnce(uint m_localID, LLUUID m_itemID, | ||
148 | string name, LLUUID keyID, int type, double range, double arc, SceneObjectPart host) | ||
149 | { | ||
150 | // Add to timer | ||
151 | SenseRepeatClass ts = new SenseRepeatClass(); | ||
152 | ts.localID = m_localID; | ||
153 | ts.itemID = m_itemID; | ||
154 | ts.interval = 0; | ||
155 | ts.name = name; | ||
156 | ts.keyID = keyID; | ||
157 | ts.type = type; | ||
158 | ts.range = range; | ||
159 | ts.arc = arc; | ||
160 | ts.host = host; | ||
161 | SensorSweep(ts); | ||
162 | } | ||
163 | |||
164 | public LSL_Types.list GetSensorList(uint m_localID, LLUUID m_itemID) | ||
165 | { | ||
166 | lock (SenseLock) | ||
167 | { | ||
168 | Dictionary<LLUUID, LSL_Types.list> Obj = null; | ||
169 | if (!SenseEvents.TryGetValue(m_localID, out Obj)) | ||
170 | { | ||
171 | m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID); | ||
172 | return null; | ||
173 | } | ||
174 | lock (Obj) | ||
175 | { | ||
176 | // Get script | ||
177 | LSL_Types.list SenseList = null; | ||
178 | if (!Obj.TryGetValue(m_itemID, out SenseList)) | ||
179 | { | ||
180 | m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID); | ||
181 | return null; | ||
182 | } | ||
183 | return SenseList; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | } | ||
188 | |||
189 | private void SensorSweep(SenseRepeatClass ts) | ||
190 | { | ||
191 | //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep"); | ||
192 | SceneObjectPart SensePoint = ts.host; | ||
193 | |||
194 | if (SensePoint == null) | ||
195 | { | ||
196 | //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString()); | ||
197 | return; | ||
198 | } | ||
199 | //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan"); | ||
200 | |||
201 | LLVector3 sensorPos = SensePoint.AbsolutePosition; | ||
202 | LLVector3 regionPos = new LLVector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0); | ||
203 | LLVector3 fromRegionPos = sensorPos + regionPos; | ||
204 | |||
205 | LLQuaternion q = SensePoint.RotationOffset; | ||
206 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | ||
207 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | ||
208 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | ||
209 | |||
210 | // Here we should do some smart culling ... | ||
211 | // math seems quicker than strings so try that first | ||
212 | LSL_Types.list SensedObjects = new LSL_Types.list(); | ||
213 | LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0); | ||
214 | |||
215 | foreach (EntityBase ent in m_CmdManager.m_ScriptEngine.World.Entities.Values) | ||
216 | { | ||
217 | |||
218 | LLVector3 toRegionPos = ent.AbsolutePosition + regionPos; | ||
219 | double dis = Math.Abs((double)Util.GetDistanceTo(toRegionPos, fromRegionPos)); | ||
220 | if (dis <= ts.range) | ||
221 | { | ||
222 | // In Range, is it the right Type ? | ||
223 | int objtype = 0; | ||
224 | |||
225 | if (m_CmdManager.m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor | ||
226 | if (ent.Velocity.Equals(ZeroVector)) | ||
227 | objtype |= 0x04; // passive non-moving | ||
228 | else | ||
229 | objtype |= 0x02; // active moving | ||
230 | if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ... | ||
231 | |||
232 | if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type)) | ||
233 | { | ||
234 | // docs claim AGENT|ACTIVE should find agent objects OR active objects | ||
235 | // so the bitwise AND with object type should be non-zero | ||
236 | |||
237 | // Right type too, what about the other params , key and name ? | ||
238 | bool keep = true; | ||
239 | if (ts.arc != Math.PI) | ||
240 | { | ||
241 | // not omni-directional. Can you see it ? | ||
242 | // vec forward_dir = llRot2Fwd(llGetRot()) | ||
243 | // vec obj_dir = toRegionPos-fromRegionPos | ||
244 | // dot=dot(forward_dir,obj_dir) | ||
245 | // mag_fwd = mag(forward_dir) | ||
246 | // mag_obj = mag(obj_dir) | ||
247 | // ang = acos( dot /(mag_fwd*mag_obj)) | ||
248 | double ang_obj = 0; | ||
249 | try | ||
250 | { | ||
251 | LLVector3 diff = toRegionPos - fromRegionPos; | ||
252 | LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); | ||
253 | double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); | ||
254 | double mag_obj = LSL_Types.Vector3.Mag(obj_dir); | ||
255 | ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); | ||
256 | } | ||
257 | catch | ||
258 | { | ||
259 | } | ||
260 | |||
261 | if (ang_obj > ts.arc) keep = false; | ||
262 | } | ||
263 | |||
264 | if (keep && (ts.name.Length > 0) && (ts.name != ent.Name)) | ||
265 | { | ||
266 | keep = false; | ||
267 | } | ||
268 | |||
269 | if (keep && (ts.keyID != null) && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID)) | ||
270 | { | ||
271 | keep = false; | ||
272 | } | ||
273 | if (keep == true) SensedObjects.Add(ent.UUID); | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock"); | ||
278 | |||
279 | lock (SenseLock) | ||
280 | { | ||
281 | // Create object if it doesn't exist | ||
282 | if (SenseEvents.ContainsKey(ts.localID) == false) | ||
283 | { | ||
284 | SenseEvents.Add(ts.localID, new Dictionary<LLUUID, LSL_Types.list>()); | ||
285 | } | ||
286 | // clear if previous traces exist | ||
287 | Dictionary<LLUUID, LSL_Types.list> Obj; | ||
288 | SenseEvents.TryGetValue(ts.localID, out Obj); | ||
289 | if (Obj.ContainsKey(ts.itemID) == true) | ||
290 | Obj.Remove(ts.itemID); | ||
291 | |||
292 | // note list may be zero length | ||
293 | Obj.Add(ts.itemID, SensedObjects); | ||
294 | |||
295 | if (SensedObjects.Length == 0) | ||
296 | { | ||
297 | // send a "no_sensor" | ||
298 | // Add it to queue | ||
299 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "no_sensor", EventQueueManager.llDetectNull, | ||
300 | new object[] { }); | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | |||
305 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull, | ||
306 | new object[] { SensedObjects.Length }); | ||
307 | } | ||
308 | } | ||
309 | } | ||
9 | } | 310 | } |
10 | } | 311 | } |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs index 6bd3752..02ef1a2 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs | |||
@@ -1,10 +1,146 @@ | |||
1 | using System; | 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 | |||
29 | using System; | ||
30 | using System.Collections; | ||
2 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
3 | using System.Text; | 32 | using System.Threading; |
33 | using libsecondlife; | ||
34 | using Axiom.Math; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; | ||
4 | 40 | ||
5 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins | 41 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins |
6 | { | 42 | { |
7 | class Timer | 43 | public class Timer |
8 | { | 44 | { |
45 | public AsyncCommandManager m_CmdManager; | ||
46 | |||
47 | public Timer(AsyncCommandManager CmdManager) | ||
48 | { | ||
49 | m_CmdManager = CmdManager; | ||
50 | } | ||
51 | |||
52 | // | ||
53 | // TIMER | ||
54 | // | ||
55 | private class TimerClass | ||
56 | { | ||
57 | public uint localID; | ||
58 | public LLUUID itemID; | ||
59 | //public double interval; | ||
60 | public long interval; | ||
61 | //public DateTime next; | ||
62 | public long next; | ||
63 | } | ||
64 | |||
65 | private List<TimerClass> Timers = new List<TimerClass>(); | ||
66 | private object TimerListLock = new object(); | ||
67 | |||
68 | public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) | ||
69 | { | ||
70 | Console.WriteLine("SetTimerEvent"); | ||
71 | |||
72 | // Always remove first, in case this is a re-set | ||
73 | UnSetTimerEvents(m_localID, m_itemID); | ||
74 | if (sec == 0) // Disabling timer | ||
75 | return; | ||
76 | |||
77 | // Add to timer | ||
78 | TimerClass ts = new TimerClass(); | ||
79 | ts.localID = m_localID; | ||
80 | ts.itemID = m_itemID; | ||
81 | ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait | ||
82 | // 2193386136332921 ticks | ||
83 | // 219338613 seconds | ||
84 | |||
85 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
86 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
87 | lock (TimerListLock) | ||
88 | { | ||
89 | Timers.Add(ts); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) | ||
94 | { | ||
95 | // Remove from timer | ||
96 | lock (TimerListLock) | ||
97 | { | ||
98 | foreach (TimerClass ts in new ArrayList(Timers)) | ||
99 | { | ||
100 | if (ts.localID == m_localID && ts.itemID == m_itemID) | ||
101 | Timers.Remove(ts); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | // Old method: Create new list | ||
106 | //List<TimerClass> NewTimers = new List<TimerClass>(); | ||
107 | //foreach (TimerClass ts in Timers) | ||
108 | //{ | ||
109 | // if (ts.localID != m_localID && ts.itemID != m_itemID) | ||
110 | // { | ||
111 | // NewTimers.Add(ts); | ||
112 | // } | ||
113 | //} | ||
114 | //Timers.Clear(); | ||
115 | //Timers = NewTimers; | ||
116 | //} | ||
117 | } | ||
118 | |||
119 | public void CheckTimerEvents() | ||
120 | { | ||
121 | // Nothing to do here? | ||
122 | if (Timers.Count == 0) | ||
123 | return; | ||
124 | |||
125 | lock (TimerListLock) | ||
126 | { | ||
127 | // Go through all timers | ||
128 | foreach (TimerClass ts in Timers) | ||
129 | { | ||
130 | // Time has passed? | ||
131 | if (ts.next < DateTime.Now.Ticks) | ||
132 | { | ||
133 | // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | ||
134 | // Add it to queue | ||
135 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull, | ||
136 | null); | ||
137 | // set next interval | ||
138 | |||
139 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
140 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | } | ||
9 | } | 145 | } |
10 | } | 146 | } |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs index 3672e14..15af51f 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs | |||
@@ -1,10 +1,111 @@ | |||
1 | using System; | 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 | |||
29 | using System; | ||
30 | using System.Collections; | ||
2 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
3 | using System.Text; | 32 | using System.Threading; |
33 | using libsecondlife; | ||
34 | using Axiom.Math; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; | ||
4 | 40 | ||
5 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins | 41 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins |
6 | { | 42 | { |
7 | class XmlRequest | 43 | public class XmlRequest |
8 | { | 44 | { |
45 | public AsyncCommandManager m_CmdManager; | ||
46 | |||
47 | public XmlRequest(AsyncCommandManager CmdManager) | ||
48 | { | ||
49 | m_CmdManager = CmdManager; | ||
50 | } | ||
51 | |||
52 | public void CheckXMLRPCRequests() | ||
53 | { | ||
54 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
55 | return; | ||
56 | |||
57 | IXMLRPC xmlrpc = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); | ||
58 | |||
59 | if (xmlrpc != null) | ||
60 | { | ||
61 | RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest(); | ||
62 | |||
63 | while (rInfo != null) | ||
64 | { | ||
65 | if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript(rInfo.GetLocalID(), rInfo.GetItemID()) != null) | ||
66 | { | ||
67 | xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID()); | ||
68 | |||
69 | //Deliver data to prim's remote_data handler | ||
70 | object[] resobj = new object[] | ||
71 | { | ||
72 | 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), String.Empty, | ||
73 | rInfo.GetIntValue(), | ||
74 | rInfo.GetStrVal() | ||
75 | }; | ||
76 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( | ||
77 | rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj | ||
78 | ); | ||
79 | } | ||
80 | |||
81 | rInfo = xmlrpc.GetNextCompletedRequest(); | ||
82 | } | ||
83 | |||
84 | SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest(); | ||
85 | |||
86 | while (srdInfo != null) | ||
87 | { | ||
88 | if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript(srdInfo.m_localID, srdInfo.m_itemID) != null) | ||
89 | { | ||
90 | xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID()); | ||
91 | |||
92 | //Deliver data to prim's remote_data handler | ||
93 | object[] resobj = new object[] | ||
94 | { | ||
95 | 3, srdInfo.channel.ToString(), srdInfo.GetReqID().ToString(), String.Empty, | ||
96 | srdInfo.idata, | ||
97 | srdInfo.sdata | ||
98 | }; | ||
99 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( | ||
100 | srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj | ||
101 | ); | ||
102 | } | ||
103 | |||
104 | srdInfo = xmlrpc.GetNextCompletedSRDRequest(); | ||
105 | } | ||
106 | } | ||
107 | } | ||
108 | |||
109 | |||
9 | } | 110 | } |
10 | } | 111 | } |