aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Scripting/XMLRPC
diff options
context:
space:
mode:
authorAdam Frisby2008-04-30 21:43:47 +0000
committerAdam Frisby2008-04-30 21:43:47 +0000
commitbe20f41637b6c06ce3ab16bc25851b6e43468e12 (patch)
treec41081329891f4c24de704fc760fb9012954ac9d /OpenSim/Region/Environment/Modules/Scripting/XMLRPC
parent* Sometimes you know, you do something really stupid. (diff)
downloadopensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.zip
opensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.gz
opensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.bz2
opensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.xz
* Cruft removal step #1. Cleaning Modules directory.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Scripting/XMLRPC')
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs214
1 files changed, 107 insertions, 107 deletions
diff --git a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
index 1139b4b..6ca8136 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
@@ -79,20 +79,21 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
79 { 79 {
80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
81 81
82 private object XMLRPCListLock = new object();
83 private string m_name = "XMLRPCModule"; 82 private string m_name = "XMLRPCModule";
84 private int RemoteReplyScriptWait = 300;
85 private int RemoteReplyScriptTimeout = 9000;
86 private int m_remoteDataPort = 0;
87 private List<Scene> m_scenes = new List<Scene>();
88 83
89 // <channel id, RPCChannelInfo> 84 // <channel id, RPCChannelInfo>
90 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels; 85 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
86 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses;
87 private int m_remoteDataPort = 0;
91 88
92 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending; 89 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending;
93 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses; 90 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses;
91 private List<Scene> m_scenes = new List<Scene>();
92 private int RemoteReplyScriptTimeout = 9000;
93 private int RemoteReplyScriptWait = 300;
94 private object XMLRPCListLock = new object();
94 95
95 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses; 96 #region IRegionModule Members
96 97
97 public void Initialise(Scene scene, IConfigSource config) 98 public void Initialise(Scene scene, IConfigSource config)
98 { 99 {
@@ -125,7 +126,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
125 // Attach xmlrpc handlers 126 // Attach xmlrpc handlers
126 m_log.Info("[REMOTE_DATA]: " + 127 m_log.Info("[REMOTE_DATA]: " +
127 "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); 128 "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
128 BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); 129 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
129 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); 130 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
130 httpServer.Start(); 131 httpServer.Start();
131 } 132 }
@@ -145,6 +146,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
145 get { return true; } 146 get { return true; }
146 } 147 }
147 148
149 #endregion
150
151 #region IXMLRPC Members
152
148 public bool IsEnabled() 153 public bool IsEnabled()
149 { 154 {
150 return (m_remoteDataPort > 0); 155 return (m_remoteDataPort > 0);
@@ -196,7 +201,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
196 // for when a script is deleted 201 // for when a script is deleted
197 public void DeleteChannels(LLUUID itemID) 202 public void DeleteChannels(LLUUID itemID)
198 { 203 {
199
200 if (m_openChannels != null) 204 if (m_openChannels != null)
201 { 205 {
202 ArrayList tmp = new ArrayList(); 206 ArrayList tmp = new ArrayList();
@@ -212,12 +216,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
212 } 216 }
213 217
214 IEnumerator tmpEnumerator = tmp.GetEnumerator(); 218 IEnumerator tmpEnumerator = tmp.GetEnumerator();
215 while ( tmpEnumerator.MoveNext() ) 219 while (tmpEnumerator.MoveNext())
216 m_openChannels.Remove((LLUUID)tmpEnumerator.Current); 220 m_openChannels.Remove((LLUUID) tmpEnumerator.Current);
217 } 221 }
218
219 } 222 }
220
221 } 223 }
222 224
223 /********************************************** 225 /**********************************************
@@ -255,67 +257,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
255 } 257 }
256 258
257 259
258 public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
259 {
260 XmlRpcResponse response = new XmlRpcResponse();
261
262 Hashtable requestData = (Hashtable)request.Params[0];
263 bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
264 requestData.Contains("StringValue"));
265
266 if (GoodXML)
267 {
268 LLUUID channel = new LLUUID((string)requestData["Channel"]);
269 RPCChannelInfo rpcChanInfo;
270 if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
271 {
272 string intVal = (string)requestData["IntValue"];
273 string strVal = (string)requestData["StringValue"];
274
275 RPCRequestInfo rpcInfo;
276
277 lock (XMLRPCListLock)
278 {
279 rpcInfo =
280 new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
281 intVal);
282 m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
283 }
284
285 int timeoutCtr = 0;
286
287 while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
288 {
289 Thread.Sleep(RemoteReplyScriptWait);
290 timeoutCtr += RemoteReplyScriptWait;
291 }
292 if (rpcInfo.IsProcessed())
293 {
294 Hashtable param = new Hashtable();
295 param["StringValue"] = rpcInfo.GetStrRetval();
296 param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
297
298 ArrayList parameters = new ArrayList();
299 parameters.Add(param);
300
301 response.Value = parameters;
302 rpcInfo = null;
303 }
304 else
305 {
306 response.SetFault(-1, "Script timeout");
307 rpcInfo = null;
308 }
309 }
310 else
311 {
312 response.SetFault(-1, "Invalid channel");
313 }
314 }
315
316 return response;
317 }
318
319 public bool hasRequests() 260 public bool hasRequests()
320 { 261 {
321 lock (XMLRPCListLock) 262 lock (XMLRPCListLock)
@@ -339,7 +280,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
339 280
340 if (m_rpcPending.TryGetValue(luid, out tmpReq)) 281 if (m_rpcPending.TryGetValue(luid, out tmpReq))
341 { 282 {
342
343 if (!tmpReq.IsProcessed()) return tmpReq; 283 if (!tmpReq.IsProcessed()) return tmpReq;
344 } 284 }
345 } 285 }
@@ -367,13 +307,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
367 307
368 public LLUUID SendRemoteData(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata) 308 public LLUUID SendRemoteData(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
369 { 309 {
370
371 SendRemoteDataRequest req = new SendRemoteDataRequest( 310 SendRemoteDataRequest req = new SendRemoteDataRequest(
372 localID, itemID, channel, dest, idata, sdata 311 localID, itemID, channel, dest, idata, sdata
373 ); 312 );
374 m_pendingSRDResponses.Add(req.GetReqID(), req); 313 m_pendingSRDResponses.Add(req.GetReqID(), req);
375 return req.process(); 314 return req.process();
376
377 } 315 }
378 316
379 public SendRemoteDataRequest GetNextCompletedSRDRequest() 317 public SendRemoteDataRequest GetNextCompletedSRDRequest()
@@ -423,19 +361,82 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
423 } 361 }
424 } 362 }
425 } 363 }
364
365 #endregion
366
367 public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
368 {
369 XmlRpcResponse response = new XmlRpcResponse();
370
371 Hashtable requestData = (Hashtable) request.Params[0];
372 bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
373 requestData.Contains("StringValue"));
374
375 if (GoodXML)
376 {
377 LLUUID channel = new LLUUID((string) requestData["Channel"]);
378 RPCChannelInfo rpcChanInfo;
379 if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
380 {
381 string intVal = (string) requestData["IntValue"];
382 string strVal = (string) requestData["StringValue"];
383
384 RPCRequestInfo rpcInfo;
385
386 lock (XMLRPCListLock)
387 {
388 rpcInfo =
389 new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
390 intVal);
391 m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
392 }
393
394 int timeoutCtr = 0;
395
396 while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
397 {
398 Thread.Sleep(RemoteReplyScriptWait);
399 timeoutCtr += RemoteReplyScriptWait;
400 }
401 if (rpcInfo.IsProcessed())
402 {
403 Hashtable param = new Hashtable();
404 param["StringValue"] = rpcInfo.GetStrRetval();
405 param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
406
407 ArrayList parameters = new ArrayList();
408 parameters.Add(param);
409
410 response.Value = parameters;
411 rpcInfo = null;
412 }
413 else
414 {
415 response.SetFault(-1, "Script timeout");
416 rpcInfo = null;
417 }
418 }
419 else
420 {
421 response.SetFault(-1, "Invalid channel");
422 }
423 }
424
425 return response;
426 }
426 } 427 }
427 428
428 public class RPCRequestInfo 429 public class RPCRequestInfo
429 { 430 {
430 private string m_StrVal; 431 private LLUUID m_ChannelKey;
431 private string m_IntVal; 432 private string m_IntVal;
432 private bool m_processed;
433 private string m_respStr;
434 private int m_respInt;
435 private uint m_localID;
436 private LLUUID m_ItemID; 433 private LLUUID m_ItemID;
434 private uint m_localID;
437 private LLUUID m_MessageID; 435 private LLUUID m_MessageID;
438 private LLUUID m_ChannelKey; 436 private bool m_processed;
437 private int m_respInt;
438 private string m_respStr;
439 private string m_StrVal;
439 440
440 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal) 441 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal)
441 { 442 {
@@ -474,6 +475,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
474 { 475 {
475 return m_respStr; 476 return m_respStr;
476 } 477 }
478
477 public void SetIntRetval(int resp) 479 public void SetIntRetval(int resp)
478 { 480 {
479 m_respInt = resp; 481 m_respInt = resp;
@@ -483,6 +485,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
483 { 485 {
484 return m_respInt; 486 return m_respInt;
485 } 487 }
488
486 public uint GetLocalID() 489 public uint GetLocalID()
487 { 490 {
488 return m_localID; 491 return m_localID;
@@ -511,9 +514,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
511 514
512 public class RPCChannelInfo 515 public class RPCChannelInfo
513 { 516 {
517 private LLUUID m_ChannelKey;
514 private LLUUID m_itemID; 518 private LLUUID m_itemID;
515 private uint m_localID; 519 private uint m_localID;
516 private LLUUID m_ChannelKey;
517 520
518 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID) 521 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID)
519 { 522 {
@@ -536,38 +539,34 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
536 { 539 {
537 return m_localID; 540 return m_localID;
538 } 541 }
539
540 } 542 }
541 543
542 public class SendRemoteDataRequest 544 public class SendRemoteDataRequest
543 { 545 {
544 546 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
545 public LLUUID reqID;
546 public string destURL;
547 public string channel; 547 public string channel;
548 public string sdata; 548 public string destURL;
549 public int idata;
550 public bool finished; 549 public bool finished;
551 public string response_sdata;
552 public int response_idata;
553 public XmlRpcRequest request;
554 private Thread httpThread; 550 private Thread httpThread;
551 public int idata;
555 public LLUUID m_itemID; 552 public LLUUID m_itemID;
556 public uint m_localID; 553 public uint m_localID;
557 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 554 public LLUUID reqID;
555 public XmlRpcRequest request;
556 public int response_idata;
557 public string response_sdata;
558 public string sdata;
558 559
559 public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata) 560 public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
560 { 561 {
561
562 this.channel = channel; 562 this.channel = channel;
563 this.destURL = dest; 563 destURL = dest;
564 this.idata = idata; 564 this.idata = idata;
565 this.sdata = sdata; 565 this.sdata = sdata;
566 m_itemID = itemID; 566 m_itemID = itemID;
567 m_localID = localID; 567 m_localID = localID;
568 568
569 reqID = LLUUID.Random(); 569 reqID = LLUUID.Random();
570
571 } 570 }
572 571
573 public LLUUID process() 572 public LLUUID process()
@@ -581,7 +580,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
581 ThreadTracker.Add(httpThread); 580 ThreadTracker.Add(httpThread);
582 581
583 return reqID; 582 return reqID;
584
585 } 583 }
586 584
587 /* 585 /*
@@ -597,8 +595,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
597 // if not, use as method name 595 // if not, use as method name
598 LLUUID parseUID; 596 LLUUID parseUID;
599 string mName = "llRemoteData"; 597 string mName = "llRemoteData";
600 if( (channel != null) && (channel != "") ) 598 if ((channel != null) && (channel != ""))
601 if( !LLUUID.TryParse(channel, out parseUID) ) 599 if (!LLUUID.TryParse(channel, out parseUID))
602 mName = channel; 600 mName = channel;
603 else 601 else
604 param["Channel"] = channel; 602 param["Channel"] = channel;
@@ -615,26 +613,28 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
615 if (resp != null) 613 if (resp != null)
616 { 614 {
617 Hashtable respParms; 615 Hashtable respParms;
618 if(resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable"))) { 616 if (resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable")))
619 respParms = (Hashtable)resp.Value; 617 {
618 respParms = (Hashtable) resp.Value;
620 } 619 }
621 else { 620 else
622 ArrayList respData = (ArrayList)resp.Value; 621 {
623 respParms = (Hashtable)respData[0]; 622 ArrayList respData = (ArrayList) resp.Value;
623 respParms = (Hashtable) respData[0];
624 } 624 }
625 if (respParms != null) 625 if (respParms != null)
626 { 626 {
627 if (respParms.Contains("StringValue")) 627 if (respParms.Contains("StringValue"))
628 { 628 {
629 sdata = (string)respParms["StringValue"]; 629 sdata = (string) respParms["StringValue"];
630 } 630 }
631 if (respParms.Contains("IntValue")) 631 if (respParms.Contains("IntValue"))
632 { 632 {
633 idata = Convert.ToInt32((string)respParms["IntValue"]); 633 idata = Convert.ToInt32((string) respParms["IntValue"]);
634 } 634 }
635 if (respParms.Contains("faultString")) 635 if (respParms.Contains("faultString"))
636 { 636 {
637 sdata = (string)respParms["faultString"]; 637 sdata = (string) respParms["faultString"];
638 } 638 }
639 if (respParms.Contains("faultCode")) 639 if (respParms.Contains("faultCode"))
640 { 640 {