XMLRPCModule.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  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 OpenSimulator 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. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Threading;
  33. using log4net;
  34. using Nini.Config;
  35. using Nwc.XmlRpc;
  36. using OpenMetaverse;
  37. using OpenSim.Framework;
  38. using OpenSim.Framework.Monitoring;
  39. using OpenSim.Framework.Servers;
  40. using OpenSim.Framework.Servers.HttpServer;
  41. using OpenSim.Region.Framework.Interfaces;
  42. using OpenSim.Region.Framework.Scenes;
  43. using Mono.Addins;
  44. using System.Net.Http;
  45. /*****************************************************
  46. *
  47. * XMLRPCModule
  48. *
  49. * Module for accepting incoming communications from
  50. * external XMLRPC client and calling a remote data
  51. * procedure for a registered data channel/prim.
  52. *
  53. *
  54. * 1. On module load, open a listener port
  55. * 2. Attach an XMLRPC handler
  56. * 3. When a request is received:
  57. * 3.1 Parse into components: channel key, int, string
  58. * 3.2 Look up registered channel listeners
  59. * 3.3 Call the channel (prim) remote data method
  60. * 3.4 Capture the response (llRemoteDataReply)
  61. * 3.5 Return response to client caller
  62. * 3.6 If no response from llRemoteDataReply within
  63. * RemoteReplyScriptTimeout, generate script timeout fault
  64. *
  65. * Prims in script must:
  66. * 1. Open a remote data channel
  67. * 1.1 Generate a channel ID
  68. * 1.2 Register primid,channelid pair with module
  69. * 2. Implement the remote data procedure handler
  70. *
  71. * llOpenRemoteDataChannel
  72. * llRemoteDataReply
  73. * remote_data(integer type, key channel, key messageid, string sender, integer ival, string sval)
  74. * llCloseRemoteDataChannel
  75. *
  76. * **************************************************/
  77. namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
  78. {
  79. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XMLRPCModule")]
  80. public class XMLRPCModule : ISharedRegionModule, IXMLRPC
  81. {
  82. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  83. private string m_name = "XMLRPCModule";
  84. // <channel id, RPCChannelInfo>
  85. private Dictionary<UUID, RPCChannelInfo> m_openChannels;
  86. private Dictionary<UUID, SendRemoteDataRequest> m_pendingSRDResponses;
  87. private int m_remoteDataPort = 0;
  88. public int Port
  89. {
  90. get { return m_remoteDataPort; }
  91. }
  92. private Dictionary<UUID, RPCRequestInfo> m_rpcPending;
  93. private Dictionary<UUID, RPCRequestInfo> m_rpcPendingResponses;
  94. private List<Scene> m_scenes = new List<Scene>();
  95. private int RemoteReplyScriptTimeout = 9000;
  96. private int RemoteReplyScriptWait = 300;
  97. private object XMLRPCListLock = new object();
  98. #region ISharedRegionModule Members
  99. public void Initialise(IConfigSource config)
  100. {
  101. // We need to create these early because the scripts might be calling
  102. // But since this gets called for every region, we need to make sure they
  103. // get called only one time (or we lose any open channels)
  104. m_openChannels = new Dictionary<UUID, RPCChannelInfo>();
  105. m_rpcPending = new Dictionary<UUID, RPCRequestInfo>();
  106. m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>();
  107. m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>();
  108. if (config.Configs["XMLRPC"] != null)
  109. {
  110. try
  111. {
  112. m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort);
  113. }
  114. catch (Exception)
  115. {
  116. }
  117. }
  118. }
  119. public void PostInitialise()
  120. {
  121. if (IsEnabled())
  122. {
  123. // Start http server
  124. // Attach xmlrpc handlers
  125. // m_log.InfoFormat(
  126. // "[XML RPC MODULE]: Starting up XMLRPC Server on port {0} for llRemoteData commands.",
  127. // m_remoteDataPort);
  128. IHttpServer httpServer = MainServer.GetHttpServer((uint)m_remoteDataPort);
  129. httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
  130. }
  131. }
  132. public void AddRegion(Scene scene)
  133. {
  134. if (!IsEnabled())
  135. return;
  136. if (!m_scenes.Contains(scene))
  137. {
  138. m_scenes.Add(scene);
  139. scene.RegisterModuleInterface<IXMLRPC>(this);
  140. }
  141. }
  142. public void RegionLoaded(Scene scene)
  143. {
  144. }
  145. public void RemoveRegion(Scene scene)
  146. {
  147. if (!IsEnabled())
  148. return;
  149. if (m_scenes.Contains(scene))
  150. {
  151. scene.UnregisterModuleInterface<IXMLRPC>(this);
  152. m_scenes.Remove(scene);
  153. }
  154. }
  155. public void Close()
  156. {
  157. }
  158. public string Name
  159. {
  160. get { return m_name; }
  161. }
  162. public Type ReplaceableInterface
  163. {
  164. get { return null; }
  165. }
  166. #endregion
  167. #region IXMLRPC Members
  168. public bool IsEnabled()
  169. {
  170. return (m_remoteDataPort > 0);
  171. }
  172. /**********************************************
  173. * OpenXMLRPCChannel
  174. *
  175. * Generate a UUID channel key and add it and
  176. * the prim id to dictionary <channelUUID, primUUID>
  177. *
  178. * A custom channel key can be proposed.
  179. * Otherwise, passing UUID.Zero will generate
  180. * and return a random channel
  181. *
  182. * First check if there is a channel assigned for
  183. * this itemID. If there is, then someone called
  184. * llOpenRemoteDataChannel twice. Just return the
  185. * original channel. Other option is to delete the
  186. * current channel and assign a new one.
  187. *
  188. * ********************************************/
  189. public UUID OpenXMLRPCChannel(uint localID, UUID itemID, UUID channelID)
  190. {
  191. UUID newChannel = UUID.Zero;
  192. // This should no longer happen, but the check is reasonable anyway
  193. if (null == m_openChannels)
  194. {
  195. m_log.Warn("[XML RPC MODULE]: Attempt to open channel before initialization is complete");
  196. return newChannel;
  197. }
  198. //Is a dupe?
  199. foreach (RPCChannelInfo ci in m_openChannels.Values)
  200. {
  201. if (ci.GetItemID().Equals(itemID))
  202. {
  203. // return the original channel ID for this item
  204. newChannel = ci.GetChannelID();
  205. break;
  206. }
  207. }
  208. if (newChannel.IsZero())
  209. {
  210. newChannel = (channelID.IsZero()) ? UUID.Random() : channelID;
  211. RPCChannelInfo rpcChanInfo = new RPCChannelInfo(localID, itemID, newChannel);
  212. lock (XMLRPCListLock)
  213. {
  214. m_openChannels.Add(newChannel, rpcChanInfo);
  215. }
  216. }
  217. return newChannel;
  218. }
  219. // Delete channels based on itemID
  220. // for when a script is deleted
  221. public void DeleteChannels(UUID itemID)
  222. {
  223. if (m_openChannels != null)
  224. {
  225. ArrayList tmp = new ArrayList();
  226. lock (XMLRPCListLock)
  227. {
  228. foreach (RPCChannelInfo li in m_openChannels.Values)
  229. {
  230. if (li.GetItemID().Equals(itemID))
  231. {
  232. tmp.Add(itemID);
  233. }
  234. }
  235. IEnumerator tmpEnumerator = tmp.GetEnumerator();
  236. while (tmpEnumerator.MoveNext())
  237. m_openChannels.Remove((UUID) tmpEnumerator.Current);
  238. }
  239. }
  240. }
  241. /**********************************************
  242. * Remote Data Reply
  243. *
  244. * Response to RPC message
  245. *
  246. *********************************************/
  247. public void RemoteDataReply(string channel, string message_id, string sdata, int idata)
  248. {
  249. UUID message_key = new UUID(message_id);
  250. UUID channel_key = new UUID(channel);
  251. RPCRequestInfo rpcInfo = null;
  252. if (message_key.IsZero())
  253. {
  254. foreach (RPCRequestInfo oneRpcInfo in m_rpcPendingResponses.Values)
  255. if (oneRpcInfo.GetChannelKey().Equals(channel_key))
  256. rpcInfo = oneRpcInfo;
  257. }
  258. else
  259. {
  260. m_rpcPendingResponses.TryGetValue(message_key, out rpcInfo);
  261. }
  262. if (rpcInfo != null)
  263. {
  264. rpcInfo.SetStrRetval(sdata);
  265. rpcInfo.SetIntRetval(idata);
  266. rpcInfo.SetProcessed(true);
  267. m_rpcPendingResponses.Remove(message_key);
  268. }
  269. else
  270. {
  271. m_log.Warn("[XML RPC MODULE]: Channel or message_id not found");
  272. }
  273. }
  274. /**********************************************
  275. * CloseXMLRPCChannel
  276. *
  277. * Remove channel from dictionary
  278. *
  279. *********************************************/
  280. public void CloseXMLRPCChannel(UUID channelKey)
  281. {
  282. if (m_openChannels.ContainsKey(channelKey))
  283. m_openChannels.Remove(channelKey);
  284. }
  285. public bool hasRequests()
  286. {
  287. lock (XMLRPCListLock)
  288. {
  289. if (m_rpcPending != null)
  290. return (m_rpcPending.Count > 0);
  291. else
  292. return false;
  293. }
  294. }
  295. public IXmlRpcRequestInfo GetNextCompletedRequest()
  296. {
  297. if (m_rpcPending != null)
  298. {
  299. lock (XMLRPCListLock)
  300. {
  301. foreach (UUID luid in m_rpcPending.Keys)
  302. {
  303. RPCRequestInfo tmpReq;
  304. if (m_rpcPending.TryGetValue(luid, out tmpReq))
  305. {
  306. if (!tmpReq.IsProcessed()) return tmpReq;
  307. }
  308. }
  309. }
  310. }
  311. return null;
  312. }
  313. public void RemoveCompletedRequest(UUID id)
  314. {
  315. lock (XMLRPCListLock)
  316. {
  317. RPCRequestInfo tmp;
  318. if (m_rpcPending.TryGetValue(id, out tmp))
  319. {
  320. m_rpcPending.Remove(id);
  321. m_rpcPendingResponses.Add(id, tmp);
  322. }
  323. else
  324. {
  325. m_log.Error("[XML RPC MODULE]: UNABLE TO REMOVE COMPLETED REQUEST");
  326. }
  327. }
  328. }
  329. public UUID SendRemoteData(uint localID, UUID itemID, string channel, string dest, int idata, string sdata)
  330. {
  331. SendRemoteDataRequest req = new SendRemoteDataRequest(
  332. localID, itemID, channel, dest, idata, sdata
  333. );
  334. m_pendingSRDResponses.Add(req.GetReqID(), req);
  335. req.Process();
  336. return req.ReqID;
  337. }
  338. public IServiceRequest GetNextCompletedSRDRequest()
  339. {
  340. if (m_pendingSRDResponses != null)
  341. {
  342. lock (XMLRPCListLock)
  343. {
  344. foreach (UUID luid in m_pendingSRDResponses.Keys)
  345. {
  346. SendRemoteDataRequest tmpReq;
  347. if (m_pendingSRDResponses.TryGetValue(luid, out tmpReq))
  348. {
  349. if (tmpReq.Finished)
  350. return tmpReq;
  351. }
  352. }
  353. }
  354. }
  355. return null;
  356. }
  357. public void RemoveCompletedSRDRequest(UUID id)
  358. {
  359. lock (XMLRPCListLock)
  360. {
  361. SendRemoteDataRequest tmpReq;
  362. if (m_pendingSRDResponses.TryGetValue(id, out tmpReq))
  363. {
  364. m_pendingSRDResponses.Remove(id);
  365. }
  366. }
  367. }
  368. public void CancelSRDRequests(UUID itemID)
  369. {
  370. if (m_pendingSRDResponses != null)
  371. {
  372. lock (XMLRPCListLock)
  373. {
  374. foreach (SendRemoteDataRequest li in m_pendingSRDResponses.Values)
  375. {
  376. if (li.ItemID.Equals(itemID))
  377. m_pendingSRDResponses.Remove(li.GetReqID());
  378. }
  379. }
  380. }
  381. }
  382. #endregion
  383. public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request, IPEndPoint remoteClient)
  384. {
  385. XmlRpcResponse response = new XmlRpcResponse();
  386. Hashtable requestData = (Hashtable) request.Params[0];
  387. bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
  388. requestData.Contains("StringValue"));
  389. if (GoodXML)
  390. {
  391. UUID channel = new UUID((string) requestData["Channel"]);
  392. RPCChannelInfo rpcChanInfo;
  393. if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
  394. {
  395. string intVal = Convert.ToInt32(requestData["IntValue"]).ToString();
  396. string strVal = (string) requestData["StringValue"];
  397. RPCRequestInfo rpcInfo;
  398. lock (XMLRPCListLock)
  399. {
  400. rpcInfo =
  401. new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
  402. intVal);
  403. m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
  404. }
  405. int timeoutCtr = 0;
  406. while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
  407. {
  408. Thread.Sleep(RemoteReplyScriptWait);
  409. timeoutCtr += RemoteReplyScriptWait;
  410. }
  411. if (rpcInfo.IsProcessed())
  412. {
  413. Hashtable param = new Hashtable();
  414. param["StringValue"] = rpcInfo.GetStrRetval();
  415. param["IntValue"] = rpcInfo.GetIntRetval();
  416. ArrayList parameters = new ArrayList();
  417. parameters.Add(param);
  418. response.Value = parameters;
  419. rpcInfo = null;
  420. }
  421. else
  422. {
  423. response.SetFault(-1, "Script timeout");
  424. rpcInfo = null;
  425. }
  426. }
  427. else
  428. {
  429. response.SetFault(-1, "Invalid channel");
  430. }
  431. }
  432. return response;
  433. }
  434. }
  435. public class RPCRequestInfo: IXmlRpcRequestInfo
  436. {
  437. private UUID m_ChannelKey;
  438. private string m_IntVal;
  439. private UUID m_ItemID;
  440. private uint m_localID;
  441. private UUID m_MessageID;
  442. private bool m_processed;
  443. private int m_respInt;
  444. private string m_respStr;
  445. private string m_StrVal;
  446. public RPCRequestInfo(uint localID, UUID itemID, UUID channelKey, string strVal, string intVal)
  447. {
  448. m_localID = localID;
  449. m_StrVal = strVal;
  450. m_IntVal = intVal;
  451. m_ItemID = itemID;
  452. m_ChannelKey = channelKey;
  453. m_MessageID = UUID.Random();
  454. m_processed = false;
  455. m_respStr = String.Empty;
  456. m_respInt = 0;
  457. }
  458. public bool IsProcessed()
  459. {
  460. return m_processed;
  461. }
  462. public UUID GetChannelKey()
  463. {
  464. return m_ChannelKey;
  465. }
  466. public void SetProcessed(bool processed)
  467. {
  468. m_processed = processed;
  469. }
  470. public void SetStrRetval(string resp)
  471. {
  472. m_respStr = resp;
  473. }
  474. public string GetStrRetval()
  475. {
  476. return m_respStr;
  477. }
  478. public void SetIntRetval(int resp)
  479. {
  480. m_respInt = resp;
  481. }
  482. public int GetIntRetval()
  483. {
  484. return m_respInt;
  485. }
  486. public uint GetLocalID()
  487. {
  488. return m_localID;
  489. }
  490. public UUID GetItemID()
  491. {
  492. return m_ItemID;
  493. }
  494. public string GetStrVal()
  495. {
  496. return m_StrVal;
  497. }
  498. public int GetIntValue()
  499. {
  500. return int.Parse(m_IntVal);
  501. }
  502. public UUID GetMessageID()
  503. {
  504. return m_MessageID;
  505. }
  506. }
  507. public class RPCChannelInfo
  508. {
  509. private UUID m_ChannelKey;
  510. private UUID m_itemID;
  511. private uint m_localID;
  512. public RPCChannelInfo(uint localID, UUID itemID, UUID channelID)
  513. {
  514. m_ChannelKey = channelID;
  515. m_localID = localID;
  516. m_itemID = itemID;
  517. }
  518. public UUID GetItemID()
  519. {
  520. return m_itemID;
  521. }
  522. public UUID GetChannelID()
  523. {
  524. return m_ChannelKey;
  525. }
  526. public uint GetLocalID()
  527. {
  528. return m_localID;
  529. }
  530. }
  531. public class SendRemoteDataRequest: IServiceRequest
  532. {
  533. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  534. public string Channel;
  535. public string DestURL;
  536. private bool _finished;
  537. public bool Finished
  538. {
  539. get { return _finished; }
  540. set { _finished = value; }
  541. }
  542. private Thread httpThread;
  543. public int Idata;
  544. private UUID _itemID;
  545. public UUID ItemID
  546. {
  547. get { return _itemID; }
  548. set { _itemID = value; }
  549. }
  550. private uint _localID;
  551. public uint LocalID
  552. {
  553. get { return _localID; }
  554. set { _localID = value; }
  555. }
  556. private UUID _reqID;
  557. public UUID ReqID
  558. {
  559. get { return _reqID; }
  560. set { _reqID = value; }
  561. }
  562. public XmlRpcRequest Request;
  563. public int ResponseIdata;
  564. public string ResponseSdata;
  565. public string Sdata;
  566. public SendRemoteDataRequest(uint localID, UUID itemID, string channel, string dest, int idata, string sdata)
  567. {
  568. this.Channel = channel;
  569. DestURL = dest;
  570. this.Idata = idata;
  571. this.Sdata = sdata;
  572. ItemID = itemID;
  573. LocalID = localID;
  574. ReqID = UUID.Random();
  575. }
  576. public void Process()
  577. {
  578. _finished = false;
  579. httpThread = WorkManager.StartThread(SendRequest, "XMLRPCreqThread", ThreadPriority.Normal, true, false, null, int.MaxValue);
  580. }
  581. /*
  582. * TODO: More work on the response codes. Right now
  583. * returning 200 for success or 499 for exception
  584. */
  585. public void SendRequest()
  586. {
  587. Hashtable param = new Hashtable();
  588. // Check if channel is an UUID
  589. // if not, use as method name
  590. UUID parseUID;
  591. string mName = "llRemoteData";
  592. if (!string.IsNullOrEmpty(Channel))
  593. if (!UUID.TryParse(Channel, out parseUID))
  594. mName = Channel;
  595. else
  596. param["Channel"] = Channel;
  597. param["StringValue"] = Sdata;
  598. param["IntValue"] = Convert.ToString(Idata);
  599. ArrayList parameters = new ArrayList();
  600. parameters.Add(param);
  601. XmlRpcRequest req = new XmlRpcRequest(mName, parameters);
  602. HttpClient hclient = null;
  603. try
  604. {
  605. hclient = WebUtil.GetNewGlobalHttpClient(-1);
  606. XmlRpcResponse resp = req.Send(DestURL, hclient);
  607. if (resp != null)
  608. {
  609. Hashtable respParms;
  610. if (resp.Value.GetType().Equals(typeof(Hashtable)))
  611. {
  612. respParms = (Hashtable) resp.Value;
  613. }
  614. else
  615. {
  616. ArrayList respData = (ArrayList) resp.Value;
  617. respParms = (Hashtable) respData[0];
  618. }
  619. if (respParms != null)
  620. {
  621. if (respParms.Contains("StringValue"))
  622. {
  623. Sdata = (string) respParms["StringValue"];
  624. }
  625. if (respParms.Contains("IntValue"))
  626. {
  627. Idata = Convert.ToInt32(respParms["IntValue"]);
  628. }
  629. if (respParms.Contains("faultString"))
  630. {
  631. Sdata = (string) respParms["faultString"];
  632. }
  633. if (respParms.Contains("faultCode"))
  634. {
  635. Idata = Convert.ToInt32(respParms["faultCode"]);
  636. }
  637. }
  638. }
  639. }
  640. catch (Exception we)
  641. {
  642. Sdata = we.Message;
  643. m_log.Warn("[SendRemoteDataRequest]: Request failed");
  644. m_log.Warn(we.StackTrace);
  645. }
  646. finally
  647. {
  648. _finished = true;
  649. httpThread = null;
  650. Watchdog.RemoveThread();
  651. hclient?.Dispose();
  652. }
  653. }
  654. public void Stop()
  655. {
  656. try
  657. {
  658. if (httpThread != null)
  659. {
  660. Watchdog.AbortThread(httpThread.ManagedThreadId);
  661. httpThread = null;
  662. }
  663. }
  664. catch (Exception)
  665. {
  666. }
  667. }
  668. public UUID GetReqID()
  669. {
  670. return ReqID;
  671. }
  672. }
  673. }