aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs127
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs98
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs76
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs334
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs139
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs130
6 files changed, 0 insertions, 904 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs
deleted file mode 100644
index 96d7b30..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs
+++ /dev/null
@@ -1,127 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using OpenMetaverse;
32using OpenSim.Region.ScriptEngine.Shared;
33
34namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
35
36{
37 public class Dataserver
38 {
39 public AsyncCommandManager m_CmdManager;
40
41 private Dictionary<string, DataserverRequest> DataserverRequests =
42 new Dictionary<string, DataserverRequest>();
43
44 public Dataserver(AsyncCommandManager CmdManager)
45 {
46 m_CmdManager = CmdManager;
47 }
48
49 private class DataserverRequest
50 {
51 public uint localID;
52 public UUID itemID;
53
54 public UUID ID;
55 public string handle;
56
57 public DateTime startTime;
58 }
59
60 public UUID RegisterRequest(uint localID, UUID itemID,
61 string identifier)
62 {
63 lock (DataserverRequests)
64 {
65 if (DataserverRequests.ContainsKey(identifier))
66 return UUID.Zero;
67
68 DataserverRequest ds = new DataserverRequest();
69
70 ds.localID = localID;
71 ds.itemID = itemID;
72
73 ds.ID = UUID.Random();
74 ds.handle = identifier;
75
76 ds.startTime = DateTime.Now;
77
78 DataserverRequests[identifier]=ds;
79
80 return ds.ID;
81 }
82 }
83
84 public void DataserverReply(string identifier, string reply)
85 {
86 DataserverRequest ds;
87
88 lock (DataserverRequests)
89 {
90 if (!DataserverRequests.ContainsKey(identifier))
91 return;
92
93 ds=DataserverRequests[identifier];
94 DataserverRequests.Remove(identifier);
95 }
96
97 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToObjectQueue(
98 ds.localID, "dataserver", EventQueueManager.llDetectNull,
99 new Object[] { new LSL_Types.LSLString(ds.ID.ToString()),
100 new LSL_Types.LSLString(reply)});
101 }
102
103 public void RemoveEvents(uint localID, UUID itemID)
104 {
105 lock (DataserverRequests)
106 {
107 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
108 {
109 if (ds.itemID == itemID)
110 DataserverRequests.Remove(ds.handle);
111 }
112 }
113 }
114
115 public void ExpireRequests()
116 {
117 lock (DataserverRequests)
118 {
119 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
120 {
121 if (ds.startTime > DateTime.Now.AddSeconds(30))
122 DataserverRequests.Remove(ds.handle);
123 }
124 }
125 }
126 }
127}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs
deleted file mode 100644
index 5b4cb83..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs
+++ /dev/null
@@ -1,98 +0,0 @@
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
28using System;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.HttpRequest;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
34{
35 public class HttpRequest
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public HttpRequest(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 public void CheckHttpRequests()
45 {
46 if (m_CmdManager.m_ScriptEngine.World == null)
47 return;
48
49 IHttpRequests iHttpReq =
50 m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
51
52 HttpRequestClass httpInfo = null;
53
54 if (iHttpReq != null)
55 httpInfo = iHttpReq.GetNextCompletedRequest();
56
57 while (httpInfo != null)
58 {
59 //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
60
61 // Deliver data to prim's remote_data handler
62 //
63 // TODO: Returning null for metadata, since the lsl function
64 // only returns the byte for HTTP_BODY_TRUNCATED, which is not
65 // implemented here yet anyway. Should be fixed if/when maxsize
66 // is supported
67
68 bool handled = false;
69 iHttpReq.RemoveCompletedRequest(httpInfo.reqID);
70 foreach (ScriptEngine sman in ScriptEngine.ScriptEngines)
71 {
72 if (sman.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null)
73 {
74 object[] resobj = new object[]
75 {
76 new LSL_Types.LSLString(httpInfo.reqID.ToString()), new LSL_Types.LSLInteger(httpInfo.status), null, new LSL_Types.LSLString(httpInfo.response_body)
77 };
78
79 sman.m_EventQueueManager.AddToScriptQueue(
80 httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj
81 );
82
83 handled = true;
84 break;
85 //Thread.Sleep(2500);
86 }
87 }
88
89 if (!handled)
90 {
91 Console.WriteLine("Unhandled http_response: " + httpInfo.reqID);
92 }
93
94 httpInfo = iHttpReq.GetNextCompletedRequest();
95 }
96 }
97 }
98}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs
deleted file mode 100644
index 0bac22c..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs
+++ /dev/null
@@ -1,76 +0,0 @@
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
28using OpenSim.Region.Environment.Interfaces;
29using OpenSim.Region.Environment.Modules.Scripting.WorldComm;
30using OpenSim.Region.ScriptEngine.Shared;
31
32namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
33{
34 public class Listener
35 {
36 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
37
38 public AsyncCommandManager m_CmdManager;
39
40 public Listener(AsyncCommandManager CmdManager)
41 {
42 m_CmdManager = CmdManager;
43 }
44
45 public void CheckListeners()
46 {
47 if (m_CmdManager.m_ScriptEngine.World == null)
48 return;
49 IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
50
51 if (comms != null)
52 {
53 while (comms.HasMessages())
54 {
55 ListenerInfo lInfo = comms.GetNextMessage();
56 if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript(
57 lInfo.GetLocalID(), lInfo.GetItemID()) != null)
58 {
59 //Deliver data to prim's listen handler
60 object[] resobj = new object[]
61 {
62 //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
63 new LSL_Types.LSLInteger(lInfo.GetChannel()), new LSL_Types.LSLString(lInfo.GetName()), new LSL_Types.LSLString(lInfo.GetID().ToString()), new LSL_Types.LSLString(lInfo.GetMessage())
64 };
65
66 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
67 lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj
68 );
69 }
70 // else
71 // m_log.Info("[ScriptEngineBase.AsyncCommandPlugins: received a listen event for a (no longer) existing script ("+lInfo.GetLocalID().AsString()+")");
72 }
73 }
74 }
75 }
76}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs
deleted file mode 100644
index 7059a1b..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs
+++ /dev/null
@@ -1,334 +0,0 @@
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//#define SPAM
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Environment.Scenes;
33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Region.ScriptEngine.Shared;
35
36namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
37{
38 public class SensorRepeat
39 {
40 public AsyncCommandManager m_CmdManager;
41
42 public SensorRepeat(AsyncCommandManager CmdManager)
43 {
44 m_CmdManager = CmdManager;
45 }
46
47 public Dictionary<uint, Dictionary<UUID, LSL_Types.list>> SenseEvents =
48 new Dictionary<uint, Dictionary<UUID, LSL_Types.list>>();
49 private Object SenseLock = new Object();
50
51 //
52 // SenseRepeater and Sensors
53 //
54 private class SenseRepeatClass
55 {
56 public uint localID;
57 public UUID itemID;
58 public double interval;
59 public DateTime next;
60
61 public string name;
62 public UUID keyID;
63 public int type;
64 public double range;
65 public double arc;
66 public SceneObjectPart host;
67 }
68
69 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
70 private object SenseRepeatListLock = new object();
71
72 public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID,
73 string name, UUID keyID, int type, double range, double arc, double sec, SceneObjectPart host)
74 {
75 #if SPAM
76 Console.WriteLine("SetSensorEvent");
77 #endif
78 // Always remove first, in case this is a re-set
79 UnSetSenseRepeaterEvents(m_localID, m_itemID);
80 if (sec == 0) // Disabling timer
81 return;
82
83 // Add to timer
84 SenseRepeatClass ts = new SenseRepeatClass();
85 ts.localID = m_localID;
86 ts.itemID = m_itemID;
87 ts.interval = sec;
88 ts.name = name;
89 ts.keyID = keyID;
90 ts.type = type;
91 ts.range = range;
92 ts.arc = arc;
93 ts.host = host;
94
95 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
96 lock (SenseRepeatListLock)
97 {
98 SenseRepeaters.Add(ts);
99 }
100 }
101
102 public void UnSetSenseRepeaterEvents(uint m_localID, UUID m_itemID)
103 {
104 // Remove from timer
105 lock (SenseRepeatListLock)
106 {
107 List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>();
108 foreach (SenseRepeatClass ts in SenseRepeaters)
109 {
110 if (ts.localID != m_localID && ts.itemID != m_itemID)
111 {
112 NewSensors.Add(ts);
113 }
114 }
115 SenseRepeaters.Clear();
116 SenseRepeaters = NewSensors;
117 }
118 }
119
120 public void CheckSenseRepeaterEvents()
121 {
122 // Nothing to do here?
123 if (SenseRepeaters.Count == 0)
124 return;
125
126 lock (SenseRepeatListLock)
127 {
128 // Go through all timers
129 foreach (SenseRepeatClass ts in SenseRepeaters)
130 {
131 // Time has passed?
132 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
133 {
134 SensorSweep(ts);
135 // set next interval
136 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
137 }
138 }
139 } // lock
140 }
141
142 public void SenseOnce(uint m_localID, UUID m_itemID,
143 string name, UUID keyID, int type,
144 double range, double arc, SceneObjectPart host)
145 {
146 // Add to timer
147 SenseRepeatClass ts = new SenseRepeatClass();
148 ts.localID = m_localID;
149 ts.itemID = m_itemID;
150 ts.interval = 0;
151 ts.name = name;
152 ts.keyID = keyID;
153 ts.type = type;
154 ts.range = range;
155 ts.arc = arc;
156 ts.host = host;
157 SensorSweep(ts);
158 }
159
160 public LSL_Types.list GetSensorList(uint m_localID, UUID m_itemID)
161 {
162 lock (SenseLock)
163 {
164 Dictionary<UUID, LSL_Types.list> Obj = null;
165 if (!SenseEvents.TryGetValue(m_localID, out Obj))
166 {
167 #if SPAM
168 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID);
169 #endif
170 return null;
171 }
172 lock (Obj)
173 {
174 // Get script
175 LSL_Types.list SenseList = null;
176 if (!Obj.TryGetValue(m_itemID, out SenseList))
177 {
178 #if SPAM
179 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID);
180 #endif
181 return null;
182 }
183 return SenseList;
184 }
185 }
186 }
187
188 private void SensorSweep(SenseRepeatClass ts)
189 {
190 //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep");
191 SceneObjectPart SensePoint = ts.host;
192
193 if (SensePoint == null)
194 {
195
196 #if SPAM
197 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString());
198 #endif
199 return;
200 }
201 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan");
202
203 Vector3 sensorPos = SensePoint.AbsolutePosition;
204 Vector3 regionPos = new Vector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
205 Vector3 fromRegionPos = sensorPos + regionPos;
206
207 Quaternion q = SensePoint.RotationOffset;
208 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
209 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
210 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
211
212 // Here we should do some smart culling ...
213 // math seems quicker than strings so try that first
214 LSL_Types.list SensedObjects = new LSL_Types.list();
215 LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0);
216
217 foreach (EntityBase ent in m_CmdManager.m_ScriptEngine.World.Entities.Values)
218 {
219 Vector3 toRegionPos = ent.AbsolutePosition + regionPos;
220 double dis = Math.Abs((double)Util.GetDistanceTo(toRegionPos, fromRegionPos));
221 if (dis <= ts.range)
222 {
223 // In Range, is it the right Type ?
224 int objtype = 0;
225
226 if (m_CmdManager.m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor
227 if (ent.Velocity.Equals(ZeroVector))
228 objtype |= 0x04; // passive non-moving
229 else
230 objtype |= 0x02; // active moving
231 if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ...
232
233 if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type))
234 {
235 // docs claim AGENT|ACTIVE should find agent objects OR active objects
236 // so the bitwise AND with object type should be non-zero
237
238 // Right type too, what about the other params , key and name ?
239 bool keep = true;
240 if (ts.arc < Math.PI)
241 {
242 // not omni-directional. Can you see it ?
243 // vec forward_dir = llRot2Fwd(llGetRot())
244 // vec obj_dir = toRegionPos-fromRegionPos
245 // dot=dot(forward_dir,obj_dir)
246 // mag_fwd = mag(forward_dir)
247 // mag_obj = mag(obj_dir)
248 // ang = acos(dot /(mag_fwd*mag_obj))
249 double ang_obj = 0;
250 try
251 {
252 Vector3 diff = toRegionPos - fromRegionPos;
253 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
254 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
255 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
256 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
257 }
258 catch
259 {
260 }
261
262 if (ang_obj > ts.arc) keep = false;
263 }
264
265 if (keep && (ts.keyID != UUID.Zero) && (ts.keyID != ent.UUID))
266 {
267 keep = false;
268 }
269
270 if (keep && (ts.name.Length > 0))
271 {
272 string avatarname=null;
273 string objectname=null;
274 string entname =ent.Name;
275
276 // try avatar username surname
277 CachedUserInfo profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserProfileCacheService.GetUserDetails(ent.UUID);
278 if (profile != null && profile.UserProfile != null)
279 {
280 avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName;
281 }
282 // try an scene object
283 SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID);
284 if (SOP != null)
285 {
286 objectname = SOP.Name;
287 }
288
289 if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname))
290 {
291 keep = false;
292 }
293 }
294
295 if (keep == true) SensedObjects.Add(ent.UUID);
296 }
297 }
298 }
299 #if SPAM
300 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock");
301 #endif
302 lock (SenseLock)
303 {
304 // Create object if it doesn't exist
305 if (SenseEvents.ContainsKey(ts.localID) == false)
306 {
307 SenseEvents.Add(ts.localID, new Dictionary<UUID, LSL_Types.list>());
308 }
309 // clear if previous traces exist
310 Dictionary<UUID, LSL_Types.list> Obj;
311 SenseEvents.TryGetValue(ts.localID, out Obj);
312 if (Obj.ContainsKey(ts.itemID) == true)
313 Obj.Remove(ts.itemID);
314
315 // note list may be zero length
316 Obj.Add(ts.itemID, SensedObjects);
317
318 if (SensedObjects.Length == 0)
319 {
320 // send a "no_sensor"
321 // Add it to queue
322 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "no_sensor", EventQueueManager.llDetectNull,
323 new object[] { });
324 }
325 else
326 {
327 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull,
328 new object[] { new LSL_Types.LSLInteger(SensedObjects.Length) });
329 }
330 m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ts.interval);
331 }
332 }
333 }
334}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs
deleted file mode 100644
index 7940b36..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs
+++ /dev/null
@@ -1,139 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using OpenMetaverse;
32
33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
34{
35 public class Timer
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public Timer(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 //
45 // TIMER
46 //
47 private class TimerClass
48 {
49 public uint localID;
50 public UUID itemID;
51 //public double interval;
52 public long interval;
53 //public DateTime next;
54 public long next;
55 }
56
57 private List<TimerClass> Timers = new List<TimerClass>();
58 private object TimerListLock = new object();
59
60 public void SetTimerEvent(uint m_localID, UUID m_itemID, double sec)
61 {
62 // Console.WriteLine("SetTimerEvent");
63
64 // Always remove first, in case this is a re-set
65 UnSetTimerEvents(m_localID, m_itemID);
66 if (sec == 0) // Disabling timer
67 return;
68
69 // Add to timer
70 TimerClass ts = new TimerClass();
71 ts.localID = m_localID;
72 ts.itemID = m_itemID;
73 ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait
74 // 2193386136332921 ticks
75 // 219338613 seconds
76
77 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
78 ts.next = DateTime.Now.Ticks + ts.interval;
79 lock (TimerListLock)
80 {
81 Timers.Add(ts);
82 }
83 }
84
85 public void UnSetTimerEvents(uint m_localID, UUID m_itemID)
86 {
87 // Remove from timer
88 lock (TimerListLock)
89 {
90 foreach (TimerClass ts in new ArrayList(Timers))
91 {
92 if (ts.localID == m_localID && ts.itemID == m_itemID)
93 Timers.Remove(ts);
94 }
95 }
96
97 // Old method: Create new list
98 //List<TimerClass> NewTimers = new List<TimerClass>();
99 //foreach (TimerClass ts in Timers)
100 //{
101 // if (ts.localID != m_localID && ts.itemID != m_itemID)
102 // {
103 // NewTimers.Add(ts);
104 // }
105 //}
106 //Timers.Clear();
107 //Timers = NewTimers;
108 //}
109 }
110
111 public void CheckTimerEvents()
112 {
113 // Nothing to do here?
114 if (Timers.Count == 0)
115 return;
116
117 lock (TimerListLock)
118 {
119 // Go through all timers
120 foreach (TimerClass ts in Timers)
121 {
122 // Time has passed?
123 if (ts.next < DateTime.Now.Ticks)
124 {
125 // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
126 // Add it to queue
127 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull,
128 null);
129 m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ((double)ts.interval / 10000000));
130 // set next interval
131
132 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
133 ts.next = DateTime.Now.Ticks + ts.interval;
134 }
135 }
136 }
137 }
138 }
139}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs
deleted file mode 100644
index 9a01cc4..0000000
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs
+++ /dev/null
@@ -1,130 +0,0 @@
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
28using System;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.XMLRPC;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins
34{
35 public class XmlRequest
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public XmlRequest(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 public void CheckXMLRPCRequests()
45 {
46 if (m_CmdManager.m_ScriptEngine.World == null)
47 return;
48
49 IXMLRPC xmlrpc = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
50 if (null == xmlrpc)
51 return;
52
53 // Process the completed request queue
54 RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest();
55
56 while (rInfo != null)
57 {
58 bool handled = false;
59
60 // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely
61 xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID());
62
63 // And since the xmlrpc request queue is actually shared among all regions on the simulator, we need
64 // to look in each one for the appropriate handler
65 foreach (ScriptEngine sman in ScriptEngine.ScriptEngines) {
66 if (sman.m_ScriptManager.GetScript(rInfo.GetLocalID(),rInfo.GetItemID()) != null) {
67
68 //Deliver data to prim's remote_data handler
69 object[] resobj = new object[]
70 {
71 new LSL_Types.LSLInteger(2), new LSL_Types.LSLString(rInfo.GetChannelKey().ToString()), new LSL_Types.LSLString(rInfo.GetMessageID().ToString()), new LSL_Types.LSLString(String.Empty),
72 new LSL_Types.LSLInteger(rInfo.GetIntValue()),
73 new LSL_Types.LSLString(rInfo.GetStrVal())
74 };
75 sman.m_EventQueueManager.AddToScriptQueue(
76 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj
77 );
78
79 handled = true;
80 }
81 }
82
83 if (! handled)
84 {
85 Console.WriteLine("Unhandled xml_request: " + rInfo.GetItemID());
86 }
87
88 rInfo = xmlrpc.GetNextCompletedRequest();
89 }
90
91 // Process the send queue
92 SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest();
93
94 while (srdInfo != null)
95 {
96 bool handled = false;
97
98 // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely
99 xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID());
100
101 // And this is another shared queue... so we check each of the script engines for a handler
102 foreach (ScriptEngine sman in ScriptEngine.ScriptEngines)
103 {
104 if (sman.m_ScriptManager.GetScript(srdInfo.m_localID,srdInfo.m_itemID) != null) {
105
106 //Deliver data to prim's remote_data handler
107 object[] resobj = new object[]
108 {
109 new LSL_Types.LSLInteger(3), new LSL_Types.LSLString(srdInfo.channel.ToString()), new LSL_Types.LSLString(srdInfo.GetReqID().ToString()), new LSL_Types.LSLString(String.Empty),
110 new LSL_Types.LSLInteger(srdInfo.idata),
111 new LSL_Types.LSLString(srdInfo.sdata)
112 };
113 sman.m_EventQueueManager.AddToScriptQueue(
114 srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj
115 );
116
117 handled = true;
118 }
119 }
120
121 if (! handled)
122 {
123 Console.WriteLine("Unhandled xml_srdrequest: " + srdInfo.GetReqID());
124 }
125
126 srdInfo = xmlrpc.GetNextCompletedSRDRequest();
127 }
128 }
129 }
130}