aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs171
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs8
4 files changed, 104 insertions, 81 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index f331b5c..fabcc2c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -47,66 +47,86 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
47 private static Thread cmdHandlerThread; 47 private static Thread cmdHandlerThread;
48 private static int cmdHandlerThreadCycleSleepms; 48 private static int cmdHandlerThreadCycleSleepms;
49 49
50 private static List<AsyncCommandManager> m_Managers = new List<AsyncCommandManager>(); 50 private static List<IScene> m_Scenes = new List<IScene>();
51 public IScriptEngine m_ScriptEngine; 51 private static List<IScriptEngine> m_ScriptEngines =
52 new List<IScriptEngine>();
52 53
53 private Dataserver m_Dataserver; 54 public IScriptEngine m_ScriptEngine;
54 private Timer m_Timer; 55 private IScene m_Scene;
55 private HttpRequest m_HttpRequest; 56
56 private Listener m_Listener; 57 private static Dictionary<IScene, Dataserver> m_Dataserver =
57 private SensorRepeat m_SensorRepeat; 58 new Dictionary<IScene, Dataserver>();
58 private XmlRequest m_XmlRequest; 59 private static Dictionary<IScene, Timer> m_Timer =
60 new Dictionary<IScene, Timer>();
61 private static Dictionary<IScene, Listener> m_Listener =
62 new Dictionary<IScene, Listener>();
63 private static Dictionary<IScene, HttpRequest> m_HttpRequest =
64 new Dictionary<IScene, HttpRequest>();
65 private static Dictionary<IScene, SensorRepeat> m_SensorRepeat =
66 new Dictionary<IScene, SensorRepeat>();
67 private static Dictionary<IScene, XmlRequest> m_XmlRequest =
68 new Dictionary<IScene, XmlRequest>();
59 69
60 public Dataserver DataserverPlugin 70 public Dataserver DataserverPlugin
61 { 71 {
62 get { return m_Dataserver; } 72 get { return m_Dataserver[m_Scene]; }
63 } 73 }
64 74
65 public Timer TimerPlugin 75 public Timer TimerPlugin
66 { 76 {
67 get { return m_Timer; } 77 get { return m_Timer[m_Scene]; }
68 } 78 }
69 79
70 public HttpRequest HttpRequestPlugin 80 public HttpRequest HttpRequestPlugin
71 { 81 {
72 get { return m_HttpRequest; } 82 get { return m_HttpRequest[m_Scene]; }
73 } 83 }
74 84
75 public Listener ListenerPlugin 85 public Listener ListenerPlugin
76 { 86 {
77 get { return m_Listener; } 87 get { return m_Listener[m_Scene]; }
78 } 88 }
79 89
80 public SensorRepeat SensorRepeatPlugin 90 public SensorRepeat SensorRepeatPlugin
81 { 91 {
82 get { return m_SensorRepeat; } 92 get { return m_SensorRepeat[m_Scene]; }
83 } 93 }
84 94
85 public XmlRequest XmlRequestPlugin 95 public XmlRequest XmlRequestPlugin
86 { 96 {
87 get { return m_XmlRequest; } 97 get { return m_XmlRequest[m_Scene]; }
88 } 98 }
89 99
90 public AsyncCommandManager[] Managers 100 public IScriptEngine[] ScriptEngines
91 { 101 {
92 get { return m_Managers.ToArray(); } 102 get { return m_ScriptEngines.ToArray(); }
93 } 103 }
94 104
95 public AsyncCommandManager(IScriptEngine _ScriptEngine) 105 public AsyncCommandManager(IScriptEngine _ScriptEngine)
96 { 106 {
97 m_ScriptEngine = _ScriptEngine; 107 m_ScriptEngine = _ScriptEngine;
98 if (!m_Managers.Contains(this)) 108 m_Scene = m_ScriptEngine.World;
99 m_Managers.Add(this); 109
110 if (!m_Scenes.Contains(m_Scene))
111 m_Scenes.Add(m_Scene);
112 if (!m_ScriptEngines.Contains(m_ScriptEngine))
113 m_ScriptEngines.Add(m_ScriptEngine);
100 114
101 ReadConfig(); 115 ReadConfig();
102 116
103 // Create instances of all plugins 117 // Create instances of all plugins
104 m_Dataserver = new Dataserver(this); 118 if (!m_Dataserver.ContainsKey(m_Scene))
105 m_Timer = new Timer(this); 119 m_Dataserver[m_Scene] = new Dataserver(this);
106 m_HttpRequest = new HttpRequest(this); 120 if (!m_Timer.ContainsKey(m_Scene))
107 m_Listener = new Listener(this); 121 m_Timer[m_Scene] = new Timer(this);
108 m_SensorRepeat = new SensorRepeat(this); 122 if (!m_HttpRequest.ContainsKey(m_Scene))
109 m_XmlRequest = new XmlRequest(this); 123 m_HttpRequest[m_Scene] = new HttpRequest(this);
124 if (!m_Listener.ContainsKey(m_Scene))
125 m_Listener[m_Scene] = new Listener(this);
126 if (!m_SensorRepeat.ContainsKey(m_Scene))
127 m_SensorRepeat[m_Scene] = new SensorRepeat(this);
128 if (!m_XmlRequest.ContainsKey(m_Scene))
129 m_XmlRequest[m_Scene] = new XmlRequest(this);
110 130
111 StartThread(); 131 StartThread();
112 } 132 }
@@ -127,26 +147,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
127 147
128 public void ReadConfig() 148 public void ReadConfig()
129 { 149 {
130 cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100); 150// cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100);
151 // TODO: Make this sane again
152 cmdHandlerThreadCycleSleepms = 100;
131 } 153 }
132 154
133 ~AsyncCommandManager() 155 ~AsyncCommandManager()
134 { 156 {
135 // Shut down thread 157 // Shut down thread
136 try 158// try
137 { 159// {
138 if (cmdHandlerThread != null) 160// if (cmdHandlerThread != null)
139 { 161// {
140 if (cmdHandlerThread.IsAlive == true) 162// if (cmdHandlerThread.IsAlive == true)
141 { 163// {
142 cmdHandlerThread.Abort(); 164// cmdHandlerThread.Abort();
143 //cmdHandlerThread.Join(); 165// //cmdHandlerThread.Join();
144 } 166// }
145 } 167// }
146 } 168// }
147 catch 169// catch
148 { 170// {
149 } 171// }
150 } 172 }
151 173
152 /// <summary> 174 /// <summary>
@@ -162,10 +184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
162 { 184 {
163 Thread.Sleep(cmdHandlerThreadCycleSleepms); 185 Thread.Sleep(cmdHandlerThreadCycleSleepms);
164 186
165 foreach (AsyncCommandManager m in m_Managers) 187 DoOneCmdHandlerPass();
166 {
167 m.DoOneCmdHandlerPass();
168 }
169 } 188 }
170 } 189 }
171 catch 190 catch
@@ -174,20 +193,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
174 } 193 }
175 } 194 }
176 195
177 public void DoOneCmdHandlerPass() 196 private static void DoOneCmdHandlerPass()
178 { 197 {
179 // Check timers 198 foreach (IScene s in m_Scenes)
180 m_Timer.CheckTimerEvents(); 199 {
181 // Check HttpRequests 200 // Check timers
182 m_HttpRequest.CheckHttpRequests(); 201 m_Timer[s].CheckTimerEvents();
183 // Check XMLRPCRequests 202 // Check HttpRequests
184 m_XmlRequest.CheckXMLRPCRequests(); 203 m_HttpRequest[s].CheckHttpRequests();
185 // Check Listeners 204 // Check XMLRPCRequests
186 m_Listener.CheckListeners(); 205 m_XmlRequest[s].CheckXMLRPCRequests();
187 // Check Sensors 206 // Check Listeners
188 m_SensorRepeat.CheckSenseRepeaterEvents(); 207 m_Listener[s].CheckListeners();
189 // Check dataserver 208 // Check Sensors
190 m_Dataserver.ExpireRequests(); 209 m_SensorRepeat[s].CheckSenseRepeaterEvents();
210 // Check dataserver
211 m_Dataserver[s].ExpireRequests();
212 }
191 } 213 }
192 214
193 /// <summary> 215 /// <summary>
@@ -195,38 +217,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
195 /// </summary> 217 /// </summary>
196 /// <param name="localID"></param> 218 /// <param name="localID"></param>
197 /// <param name="itemID"></param> 219 /// <param name="itemID"></param>
198 public void RemoveScript(uint localID, UUID itemID) 220 public static void RemoveScript(IScene scene, uint localID, UUID itemID)
199 { 221 {
200 // Remove a specific script 222 // Remove a specific script
201 223
202 // Remove dataserver events 224 // Remove dataserver events
203 m_Dataserver.RemoveEvents(localID, itemID); 225 m_Dataserver[scene].RemoveEvents(localID, itemID);
204 226
205 // Remove from: Timers 227 // Remove from: Timers
206 m_Timer.UnSetTimerEvents(localID, itemID); 228 m_Timer[scene].UnSetTimerEvents(localID, itemID);
207 229
208 // Remove from: HttpRequest 230 // Remove from: HttpRequest
209 IHttpRequests iHttpReq = 231 IHttpRequests iHttpReq =
210 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); 232 scene.RequestModuleInterface<IHttpRequests>();
211 iHttpReq.StopHttpRequest(localID, itemID); 233 iHttpReq.StopHttpRequest(localID, itemID);
212 234
213 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 235 IWorldComm comms = scene.RequestModuleInterface<IWorldComm>();
214 comms.DeleteListener(itemID); 236 comms.DeleteListener(itemID);
215 237
216 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 238 IXMLRPC xmlrpc = scene.RequestModuleInterface<IXMLRPC>();
217 xmlrpc.DeleteChannels(itemID); 239 xmlrpc.DeleteChannels(itemID);
218 xmlrpc.CancelSRDRequests(itemID); 240 xmlrpc.CancelSRDRequests(itemID);
219 241
220 // Remove Sensors 242 // Remove Sensors
221 m_SensorRepeat.UnSetSenseRepeaterEvents(localID, itemID); 243 m_SensorRepeat[scene].UnSetSenseRepeaterEvents(localID, itemID);
222 244
223 } 245 }
224 246
225 public Object[] GetSerializationData(UUID itemID) 247 public static Object[] GetSerializationData(IScene scene, UUID itemID)
226 { 248 {
227 List<Object> data = new List<Object>(); 249 List<Object> data = new List<Object>();
228 250
229 Object[] listeners=m_Listener.GetSerializationData(itemID); 251 Object[] listeners=m_Listener[scene].GetSerializationData(itemID);
230 if (listeners.Length > 0) 252 if (listeners.Length > 0)
231 { 253 {
232 data.Add("listener"); 254 data.Add("listener");
@@ -234,7 +256,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
234 data.AddRange(listeners); 256 data.AddRange(listeners);
235 } 257 }
236 258
237 Object[] timers=m_Timer.GetSerializationData(itemID); 259 Object[] timers=m_Timer[scene].GetSerializationData(itemID);
238 if (timers.Length > 0) 260 if (timers.Length > 0)
239 { 261 {
240 data.Add("timer"); 262 data.Add("timer");
@@ -242,7 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
242 data.AddRange(timers); 264 data.AddRange(timers);
243 } 265 }
244 266
245 Object[] sensors=m_SensorRepeat.GetSerializationData(itemID); 267 Object[] sensors=m_SensorRepeat[scene].GetSerializationData(itemID);
246 if (sensors.Length > 0) 268 if (sensors.Length > 0)
247 { 269 {
248 data.Add("sensor"); 270 data.Add("sensor");
@@ -253,8 +275,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
253 return data.ToArray(); 275 return data.ToArray();
254 } 276 }
255 277
256 public void CreateFromData(uint localID, UUID itemID, UUID hostID, 278 public static void CreateFromData(IScene scene, uint localID,
257 Object[] data) 279 UUID itemID, UUID hostID, Object[] data)
258 { 280 {
259 int idx = 0; 281 int idx = 0;
260 int len; 282 int len;
@@ -275,15 +297,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
275 switch (type) 297 switch (type)
276 { 298 {
277 case "listener": 299 case "listener":
278 m_Listener.CreateFromData(localID, itemID, hostID, 300 m_Listener[scene].CreateFromData(localID, itemID,
279 item); 301 hostID, item);
280 break; 302 break;
281 case "timer": 303 case "timer":
282 m_Timer.CreateFromData(localID, itemID, hostID, item); 304 m_Timer[scene].CreateFromData(localID, itemID,
305 hostID, item);
283 break; 306 break;
284 case "sensor": 307 case "sensor":
285 m_SensorRepeat.CreateFromData(localID, itemID, hostID, 308 m_SensorRepeat[scene].CreateFromData(localID,
286 item); 309 itemID, hostID, item);
287 break; 310 break;
288 } 311 }
289 } 312 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 512fcd9..552d47c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -92,7 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
92 m_ScriptDistanceFactor = config.Configs["XEngine"]. 92 m_ScriptDistanceFactor = config.Configs["XEngine"].
93 GetFloat("ScriptDistanceLimitFactor", 1.0f); 93 GetFloat("ScriptDistanceLimitFactor", 1.0f);
94 94
95 AsyncCommands = (AsyncCommandManager)ScriptEngine.AsyncCommands; 95 AsyncCommands = new AsyncCommandManager(ScriptEngine);
96 } 96 }
97 97
98 private DateTime m_timer = DateTime.Now; 98 private DateTime m_timer = DateTime.Now;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
index 92f603d..3d3fb05 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs
@@ -77,9 +77,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
77 new LSL_Types.LSLString(httpInfo.response_body) 77 new LSL_Types.LSLString(httpInfo.response_body)
78 }; 78 };
79 79
80 foreach (AsyncCommandManager m in m_CmdManager.Managers) 80 foreach (IScriptEngine e in m_CmdManager.ScriptEngines)
81 { 81 {
82 if (m.m_ScriptEngine.PostObjectEvent(httpInfo.localID, 82 if (e.PostObjectEvent(httpInfo.localID,
83 new EventParams("http_response", 83 new EventParams("http_response",
84 resobj, new DetectParams[0]))) 84 resobj, new DetectParams[0])))
85 break; 85 break;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
index 3f3cf39..a7699a1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs
@@ -71,9 +71,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
71 new LSL_Types.LSLString(rInfo.GetStrVal()) 71 new LSL_Types.LSLString(rInfo.GetStrVal())
72 }; 72 };
73 73
74 foreach (AsyncCommandManager m in m_CmdManager.Managers) 74 foreach (IScriptEngine e in m_CmdManager.ScriptEngines)
75 { 75 {
76 if (m.m_ScriptEngine.PostScriptEvent( 76 if (e.PostScriptEvent(
77 rInfo.GetItemID(), new EventParams( 77 rInfo.GetItemID(), new EventParams(
78 "remote_data", resobj, 78 "remote_data", resobj,
79 new DetectParams[0]))) 79 new DetectParams[0])))
@@ -100,9 +100,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
100 new LSL_Types.LSLString(srdInfo.sdata) 100 new LSL_Types.LSLString(srdInfo.sdata)
101 }; 101 };
102 102
103 foreach (AsyncCommandManager m in m_CmdManager.Managers) 103 foreach (IScriptEngine e in m_CmdManager.ScriptEngines)
104 { 104 {
105 if (m.m_ScriptEngine.PostScriptEvent( 105 if (e.PostScriptEvent(
106 srdInfo.m_itemID, new EventParams( 106 srdInfo.m_itemID, new EventParams(
107 "remote_data", resobj, 107 "remote_data", resobj,
108 new DetectParams[0]))) 108 new DetectParams[0])))