aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs160
1 files changed, 46 insertions, 114 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
index 5061629..ddc0c62 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
@@ -110,7 +110,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
110 // Remove from: Timers 110 // Remove from: Timers
111 UnSetTimerEvents(localID, itemID); 111 UnSetTimerEvents(localID, itemID);
112 // Remove from: HttpRequest 112 // Remove from: HttpRequest
113 StopHttpRequest(localID, itemID); 113 IHttpRequests iHttpReq =
114 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
115 iHttpReq.StopHttpRequest(localID, itemID);
114 } 116 }
115 117
116 #region TIMER 118 #region TIMER
@@ -198,136 +200,67 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
198 200
199 #region HTTP REQUEST 201 #region HTTP REQUEST
200 202
201 // 203 public void CheckHttpRequests()
202 // HTTP REAQUEST
203 //
204 private class HttpClass
205 { 204 {
206 public uint localID; 205 IHttpRequests iHttpReq =
207 public LLUUID itemID; 206 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
208 public string url;
209 public List<string> parameters;
210 public string body;
211 public DateTime next;
212 207
213 public string response_request_id; 208 HttpRequestClass httpInfo = null;
214 public int response_status;
215 public List<string> response_metadata;
216 public string response_body;
217 209
218 public void SendRequest() 210 if( iHttpReq != null )
219 { 211 httpInfo = iHttpReq.GetNextCompletedRequest();
220 // TODO: SEND REQUEST!!!
221 }
222
223 public void Stop()
224 {
225 // TODO: Cancel any ongoing request
226 }
227 212
228 public bool CheckResponse() 213 while ( httpInfo != null )
229 { 214 {
230 // TODO: Check if we got a response yet, return true if so -- false if not 215
231 return true; 216 Console.WriteLine("PICKED HTTP REQ:" + httpInfo.response_body + httpInfo.status);
232 217
233 // TODO: If we got a response, set the following then return true 218 // Deliver data to prim's remote_data handler
234 //response_request_id 219 //
235 //response_status 220 // TODO: Returning null for metadata, since the lsl function
236 //response_metadata 221 // only returns the byte for HTTP_BODY_TRUNCATED, which is not
237 //response_body 222 // implemented here yet anyway. Should be fixed if/when maxsize
238 } 223 // is supported
239 } 224
225 object[] resobj = new object[]
226 {
227 httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body
228 };
240 229
241 private List<HttpClass> HttpRequests = new List<HttpClass>(); 230 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
242 private object HttpListLock = new object(); 231 httpInfo.localID, httpInfo.itemID, "http_response", resobj
232 );
243 233
244 public void StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body) 234 httpInfo.Stop();
245 { 235 httpInfo = null;
246 Console.WriteLine("StartHttpRequest");
247
248 HttpClass htc = new HttpClass();
249 htc.localID = localID;
250 htc.itemID = itemID;
251 htc.url = url;
252 htc.parameters = parameters;
253 htc.body = body;
254 lock (HttpListLock)
255 {
256 //ADD REQUEST
257 HttpRequests.Add(htc);
258 }
259 }
260 236
261 public void StopHttpRequest(uint m_localID, LLUUID m_itemID) 237 httpInfo = iHttpReq.GetNextCompletedRequest();
262 {
263 // Remove from list
264 lock (HttpListLock)
265 {
266 List<HttpClass> NewHttpList = new List<HttpClass>();
267 foreach (HttpClass ts in HttpRequests)
268 {
269 if (ts.localID != m_localID && ts.itemID != m_itemID)
270 {
271 // Keeping this one
272 NewHttpList.Add(ts);
273 }
274 else
275 {
276 // Shutting this one down
277 ts.Stop();
278 }
279 }
280 HttpRequests.Clear();
281 HttpRequests = NewHttpList;
282 } 238 }
283 } 239 }
284 240
285 public void CheckHttpRequests()
286 {
287 // Nothing to do here?
288 if (HttpRequests.Count == 0)
289 return;
290
291 lock (HttpListLock)
292 {
293 foreach (HttpClass ts in HttpRequests)
294 {
295 if (ts.CheckResponse() == true)
296 {
297 // Add it to event queue
298 //key request_id, integer status, list metadata, string body
299 object[] resobj =
300 new object[]
301 {ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body};
302 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response",
303 resobj);
304 // Now stop it
305 StopHttpRequest(ts.localID, ts.itemID);
306 }
307 }
308 } // lock
309 }
310
311 #endregion 241 #endregion
312 242
313 public void CheckXMLRPCRequests() 243 public void CheckXMLRPCRequests()
314 { 244 {
315 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 245 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
316 246
317 while (xmlrpc.hasRequests()) 247 if (xmlrpc != null)
318 { 248 {
319 RPCRequestInfo rInfo = xmlrpc.GetNextRequest(); 249 while (xmlrpc.hasRequests())
320 Console.WriteLine("PICKED REQUEST"); 250 {
321 251 RPCRequestInfo rInfo = xmlrpc.GetNextRequest();
322 //Deliver data to prim's remote_data handler 252 Console.WriteLine("PICKED REQUEST");
323 object[] resobj = new object[] 253
324 { 254 //Deliver data to prim's remote_data handler
325 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), 255 object[] resobj = new object[]
326 rInfo.GetStrVal() 256 {
327 }; 257 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(),
328 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 258 rInfo.GetStrVal()
329 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj 259 };
330 ); 260 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
261 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj
262 );
263 }
331 } 264 }
332 } 265 }
333 266
@@ -338,7 +271,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
338 while (comms.HasMessages()) 271 while (comms.HasMessages())
339 { 272 {
340 ListenerInfo lInfo = comms.GetNextMessage(); 273 ListenerInfo lInfo = comms.GetNextMessage();
341 Console.WriteLine("PICKED LISTENER");
342 274
343 //Deliver data to prim's listen handler 275 //Deliver data to prim's listen handler
344 object[] resobj = new object[] 276 object[] resobj = new object[]