UserAgentServiceConnector.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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.IO;
  31. using System.Net;
  32. using System.Reflection;
  33. using System.Text;
  34. using OpenSim.Framework;
  35. using OpenSim.Services.Interfaces;
  36. using OpenSim.Services.Connectors.Simulation;
  37. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  38. using OpenMetaverse;
  39. using OpenMetaverse.StructuredData;
  40. using log4net;
  41. using Nwc.XmlRpc;
  42. using Nini.Config;
  43. namespace OpenSim.Services.Connectors.Hypergrid
  44. {
  45. public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService
  46. {
  47. private static readonly ILog m_log =
  48. LogManager.GetLogger(
  49. MethodBase.GetCurrentMethod().DeclaringType);
  50. private string m_ServerURLHost;
  51. private string m_ServerURL;
  52. private GridRegion m_Gatekeeper;
  53. public UserAgentServiceConnector(string url) : this(url, true)
  54. {
  55. }
  56. public UserAgentServiceConnector(string url, bool dnsLookup)
  57. {
  58. m_ServerURL = m_ServerURLHost = url;
  59. if (dnsLookup)
  60. {
  61. // Doing this here, because XML-RPC or mono have some strong ideas about
  62. // caching DNS translations.
  63. try
  64. {
  65. Uri m_Uri = new Uri(m_ServerURL);
  66. IPAddress ip = Util.GetHostFromDNS(m_Uri.Host);
  67. m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString());
  68. if (!m_ServerURL.EndsWith("/"))
  69. m_ServerURL += "/";
  70. }
  71. catch (Exception e)
  72. {
  73. m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", url, e.Message);
  74. }
  75. }
  76. //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
  77. }
  78. public UserAgentServiceConnector(IConfigSource config)
  79. {
  80. IConfig serviceConfig = config.Configs["UserAgentService"];
  81. if (serviceConfig == null)
  82. {
  83. m_log.Error("[USER AGENT CONNECTOR]: UserAgentService missing from ini");
  84. throw new Exception("UserAgent connector init error");
  85. }
  86. string serviceURI = serviceConfig.GetString("UserAgentServerURI",
  87. String.Empty);
  88. if (serviceURI == String.Empty)
  89. {
  90. m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService");
  91. throw new Exception("UserAgent connector init error");
  92. }
  93. m_ServerURL = m_ServerURLHost = serviceURI;
  94. if (!m_ServerURL.EndsWith("/"))
  95. m_ServerURL += "/";
  96. //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0}", m_ServerURL);
  97. }
  98. protected override string AgentPath()
  99. {
  100. return "homeagent/";
  101. }
  102. // The Login service calls this interface with fromLogin=true
  103. // Sims call it with fromLogin=false
  104. // Either way, this is verified by the handler
  105. public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
  106. {
  107. reason = String.Empty;
  108. if (destination == null)
  109. {
  110. reason = "Destination is null";
  111. m_log.Debug("[USER AGENT CONNECTOR]: Given destination is null");
  112. return false;
  113. }
  114. GridRegion home = new GridRegion();
  115. home.ServerURI = m_ServerURL;
  116. home.RegionID = destination.RegionID;
  117. home.RegionLocX = destination.RegionLocX;
  118. home.RegionLocY = destination.RegionLocY;
  119. m_Gatekeeper = gatekeeper;
  120. Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
  121. uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
  122. return CreateAgent(home, aCircuit, flags, out reason);
  123. }
  124. // The simulators call this interface
  125. public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
  126. {
  127. return LoginAgentToGrid(aCircuit, gatekeeper, destination, false, out reason);
  128. }
  129. protected override void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
  130. {
  131. base.PackData(args, aCircuit, destination, flags);
  132. args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI);
  133. args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName);
  134. args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString());
  135. args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
  136. }
  137. protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
  138. {
  139. OSDMap args = null;
  140. try
  141. {
  142. args = aCircuit.PackAgentCircuitData();
  143. }
  144. catch (Exception e)
  145. {
  146. m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
  147. }
  148. // Add the input arguments
  149. args["gatekeeper_serveruri"] = OSD.FromString(gatekeeper.ServerURI);
  150. args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName);
  151. args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString());
  152. args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
  153. args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
  154. args["destination_name"] = OSD.FromString(destination.RegionName);
  155. args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
  156. args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
  157. // 10/3/2010
  158. // I added the client_ip up to the regular AgentCircuitData, so this doesn't need to be here.
  159. // This need cleaning elsewhere...
  160. //if (ipaddress != null)
  161. // args["client_ip"] = OSD.FromString(ipaddress.Address.ToString());
  162. return args;
  163. }
  164. public void SetClientToken(UUID sessionID, string token)
  165. {
  166. // no-op
  167. }
  168. private Hashtable CallServer(string methodName, Hashtable hash)
  169. {
  170. IList paramList = new ArrayList();
  171. paramList.Add(hash);
  172. XmlRpcRequest request = new XmlRpcRequest(methodName, paramList);
  173. // Send and get reply
  174. XmlRpcResponse response = null;
  175. try
  176. {
  177. response = request.Send(m_ServerURL, 10000);
  178. }
  179. catch (Exception e)
  180. {
  181. m_log.DebugFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURLHost, e.Message);
  182. throw;
  183. }
  184. if (response.IsFault)
  185. {
  186. throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURLHost, response.FaultString));
  187. }
  188. hash = (Hashtable)response.Value;
  189. if (hash == null)
  190. {
  191. throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURLHost));
  192. }
  193. return hash;
  194. }
  195. public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
  196. {
  197. position = Vector3.UnitY; lookAt = Vector3.UnitY;
  198. Hashtable hash = new Hashtable();
  199. hash["userID"] = userID.ToString();
  200. hash = CallServer("get_home_region", hash);
  201. bool success;
  202. if (!Boolean.TryParse((string)hash["result"], out success) || !success)
  203. return null;
  204. GridRegion region = new GridRegion();
  205. UUID.TryParse((string)hash["uuid"], out region.RegionID);
  206. //m_log.Debug(">> HERE, uuid: " + region.RegionID);
  207. int n = 0;
  208. if (hash["x"] != null)
  209. {
  210. Int32.TryParse((string)hash["x"], out n);
  211. region.RegionLocX = n;
  212. //m_log.Debug(">> HERE, x: " + region.RegionLocX);
  213. }
  214. if (hash["y"] != null)
  215. {
  216. Int32.TryParse((string)hash["y"], out n);
  217. region.RegionLocY = n;
  218. //m_log.Debug(">> HERE, y: " + region.RegionLocY);
  219. }
  220. if (hash["size_x"] != null)
  221. {
  222. Int32.TryParse((string)hash["size_x"], out n);
  223. region.RegionSizeX = n;
  224. //m_log.Debug(">> HERE, x: " + region.RegionLocX);
  225. }
  226. if (hash["size_y"] != null)
  227. {
  228. Int32.TryParse((string)hash["size_y"], out n);
  229. region.RegionSizeY = n;
  230. //m_log.Debug(">> HERE, y: " + region.RegionLocY);
  231. }
  232. if (hash["region_name"] != null)
  233. {
  234. region.RegionName = (string)hash["region_name"];
  235. //m_log.Debug(">> HERE, name: " + region.RegionName);
  236. }
  237. if (hash["hostname"] != null)
  238. region.ExternalHostName = (string)hash["hostname"];
  239. if (hash["http_port"] != null)
  240. {
  241. uint p = 0;
  242. UInt32.TryParse((string)hash["http_port"], out p);
  243. region.HttpPort = p;
  244. }
  245. if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
  246. region.ServerURI = (string)hash["server_uri"];
  247. if (hash["internal_port"] != null)
  248. {
  249. int p = 0;
  250. Int32.TryParse((string)hash["internal_port"], out p);
  251. region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
  252. }
  253. if (hash["position"] != null)
  254. Vector3.TryParse((string)hash["position"], out position);
  255. if (hash["lookAt"] != null)
  256. Vector3.TryParse((string)hash["lookAt"], out lookAt);
  257. // Successful return
  258. return region;
  259. }
  260. public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
  261. {
  262. Hashtable hash = new Hashtable();
  263. hash["sessionID"] = sessionID.ToString();
  264. hash["externalName"] = thisGridExternalName;
  265. IList paramList = new ArrayList();
  266. paramList.Add(hash);
  267. XmlRpcRequest request = new XmlRpcRequest("agent_is_coming_home", paramList);
  268. string reason = string.Empty;
  269. return GetBoolResponse(request, out reason);
  270. }
  271. public bool VerifyAgent(UUID sessionID, string token)
  272. {
  273. Hashtable hash = new Hashtable();
  274. hash["sessionID"] = sessionID.ToString();
  275. hash["token"] = token;
  276. IList paramList = new ArrayList();
  277. paramList.Add(hash);
  278. XmlRpcRequest request = new XmlRpcRequest("verify_agent", paramList);
  279. string reason = string.Empty;
  280. return GetBoolResponse(request, out reason);
  281. }
  282. public bool VerifyClient(UUID sessionID, string token)
  283. {
  284. Hashtable hash = new Hashtable();
  285. hash["sessionID"] = sessionID.ToString();
  286. hash["token"] = token;
  287. IList paramList = new ArrayList();
  288. paramList.Add(hash);
  289. XmlRpcRequest request = new XmlRpcRequest("verify_client", paramList);
  290. string reason = string.Empty;
  291. return GetBoolResponse(request, out reason);
  292. }
  293. public void LogoutAgent(UUID userID, UUID sessionID)
  294. {
  295. Hashtable hash = new Hashtable();
  296. hash["sessionID"] = sessionID.ToString();
  297. hash["userID"] = userID.ToString();
  298. IList paramList = new ArrayList();
  299. paramList.Add(hash);
  300. XmlRpcRequest request = new XmlRpcRequest("logout_agent", paramList);
  301. string reason = string.Empty;
  302. GetBoolResponse(request, out reason);
  303. }
  304. [Obsolete]
  305. public List<UUID> StatusNotification(List<string> friends, UUID userID, bool online)
  306. {
  307. Hashtable hash = new Hashtable();
  308. hash["userID"] = userID.ToString();
  309. hash["online"] = online.ToString();
  310. int i = 0;
  311. foreach (string s in friends)
  312. {
  313. hash["friend_" + i.ToString()] = s;
  314. i++;
  315. }
  316. IList paramList = new ArrayList();
  317. paramList.Add(hash);
  318. XmlRpcRequest request = new XmlRpcRequest("status_notification", paramList);
  319. // string reason = string.Empty;
  320. // Send and get reply
  321. List<UUID> friendsOnline = new List<UUID>();
  322. XmlRpcResponse response = null;
  323. try
  324. {
  325. response = request.Send(m_ServerURL, 6000);
  326. }
  327. catch
  328. {
  329. m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURLHost);
  330. // reason = "Exception: " + e.Message;
  331. return friendsOnline;
  332. }
  333. if (response.IsFault)
  334. {
  335. m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURLHost, response.FaultString);
  336. // reason = "XMLRPC Fault";
  337. return friendsOnline;
  338. }
  339. hash = (Hashtable)response.Value;
  340. //foreach (Object o in hash)
  341. // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
  342. try
  343. {
  344. if (hash == null)
  345. {
  346. m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
  347. // reason = "Internal error 1";
  348. return friendsOnline;
  349. }
  350. // Here is the actual response
  351. foreach (object key in hash.Keys)
  352. {
  353. if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null)
  354. {
  355. UUID uuid;
  356. if (UUID.TryParse(hash[key].ToString(), out uuid))
  357. friendsOnline.Add(uuid);
  358. }
  359. }
  360. }
  361. catch
  362. {
  363. m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
  364. // reason = "Exception: " + e.Message;
  365. }
  366. return friendsOnline;
  367. }
  368. [Obsolete]
  369. public List<UUID> GetOnlineFriends(UUID userID, List<string> friends)
  370. {
  371. Hashtable hash = new Hashtable();
  372. hash["userID"] = userID.ToString();
  373. int i = 0;
  374. foreach (string s in friends)
  375. {
  376. hash["friend_" + i.ToString()] = s;
  377. i++;
  378. }
  379. IList paramList = new ArrayList();
  380. paramList.Add(hash);
  381. XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList);
  382. // string reason = string.Empty;
  383. // Send and get reply
  384. List<UUID> online = new List<UUID>();
  385. XmlRpcResponse response = null;
  386. try
  387. {
  388. response = request.Send(m_ServerURL, 10000);
  389. }
  390. catch
  391. {
  392. m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURLHost);
  393. // reason = "Exception: " + e.Message;
  394. return online;
  395. }
  396. if (response.IsFault)
  397. {
  398. m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURLHost, response.FaultString);
  399. // reason = "XMLRPC Fault";
  400. return online;
  401. }
  402. hash = (Hashtable)response.Value;
  403. //foreach (Object o in hash)
  404. // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
  405. try
  406. {
  407. if (hash == null)
  408. {
  409. m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
  410. // reason = "Internal error 1";
  411. return online;
  412. }
  413. // Here is the actual response
  414. foreach (object key in hash.Keys)
  415. {
  416. if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null)
  417. {
  418. UUID uuid;
  419. if (UUID.TryParse(hash[key].ToString(), out uuid))
  420. online.Add(uuid);
  421. }
  422. }
  423. }
  424. catch
  425. {
  426. m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
  427. // reason = "Exception: " + e.Message;
  428. }
  429. return online;
  430. }
  431. public Dictionary<string,object> GetUserInfo (UUID userID)
  432. {
  433. Hashtable hash = new Hashtable();
  434. hash["userID"] = userID.ToString();
  435. hash = CallServer("get_user_info", hash);
  436. Dictionary<string, object> info = new Dictionary<string, object>();
  437. foreach (object key in hash.Keys)
  438. {
  439. if (hash[key] != null)
  440. {
  441. info.Add(key.ToString(), hash[key]);
  442. }
  443. }
  444. return info;
  445. }
  446. public Dictionary<string, object> GetServerURLs(UUID userID)
  447. {
  448. Hashtable hash = new Hashtable();
  449. hash["userID"] = userID.ToString();
  450. hash = CallServer("get_server_urls", hash);
  451. Dictionary<string, object> serverURLs = new Dictionary<string, object>();
  452. foreach (object key in hash.Keys)
  453. {
  454. if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
  455. {
  456. string serverType = key.ToString().Substring(4); // remove "SRV_"
  457. serverURLs.Add(serverType, hash[key].ToString());
  458. }
  459. }
  460. return serverURLs;
  461. }
  462. public string LocateUser(UUID userID)
  463. {
  464. Hashtable hash = new Hashtable();
  465. hash["userID"] = userID.ToString();
  466. hash = CallServer("locate_user", hash);
  467. string url = string.Empty;
  468. // Here's the actual response
  469. if (hash.ContainsKey("URL"))
  470. url = hash["URL"].ToString();
  471. return url;
  472. }
  473. public string GetUUI(UUID userID, UUID targetUserID)
  474. {
  475. Hashtable hash = new Hashtable();
  476. hash["userID"] = userID.ToString();
  477. hash["targetUserID"] = targetUserID.ToString();
  478. hash = CallServer("get_uui", hash);
  479. string uui = string.Empty;
  480. // Here's the actual response
  481. if (hash.ContainsKey("UUI"))
  482. uui = hash["UUI"].ToString();
  483. return uui;
  484. }
  485. public UUID GetUUID(String first, String last)
  486. {
  487. Hashtable hash = new Hashtable();
  488. hash["first"] = first;
  489. hash["last"] = last;
  490. hash = CallServer("get_uuid", hash);
  491. if (!hash.ContainsKey("UUID"))
  492. {
  493. throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURLHost));
  494. }
  495. UUID uuid;
  496. if (!UUID.TryParse(hash["UUID"].ToString(), out uuid))
  497. {
  498. throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURLHost, hash["UUID"].ToString()));
  499. }
  500. return uuid;
  501. }
  502. private bool GetBoolResponse(XmlRpcRequest request, out string reason)
  503. {
  504. //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURLHost);
  505. XmlRpcResponse response = null;
  506. try
  507. {
  508. response = request.Send(m_ServerURL, 10000);
  509. }
  510. catch (Exception e)
  511. {
  512. m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURLHost);
  513. reason = "Exception: " + e.Message;
  514. return false;
  515. }
  516. if (response.IsFault)
  517. {
  518. m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURLHost, response.FaultString);
  519. reason = "XMLRPC Fault";
  520. return false;
  521. }
  522. Hashtable hash = (Hashtable)response.Value;
  523. //foreach (Object o in hash)
  524. // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
  525. try
  526. {
  527. if (hash == null)
  528. {
  529. m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
  530. reason = "Internal error 1";
  531. return false;
  532. }
  533. bool success = false;
  534. reason = string.Empty;
  535. if (hash.ContainsKey("result"))
  536. Boolean.TryParse((string)hash["result"], out success);
  537. else
  538. {
  539. reason = "Internal error 2";
  540. m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURLHost);
  541. }
  542. return success;
  543. }
  544. catch (Exception e)
  545. {
  546. m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetBoolResponse response.");
  547. if (hash.ContainsKey("result") && hash["result"] != null)
  548. m_log.ErrorFormat("Reply was ", (string)hash["result"]);
  549. reason = "Exception: " + e.Message;
  550. return false;
  551. }
  552. }
  553. }
  554. }