MessageService.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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 OpenSim 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 libsecondlife;
  34. using log4net;
  35. using Nwc.XmlRpc;
  36. using OpenSim.Data;
  37. using OpenSim.Framework;
  38. //using System.Xml;
  39. namespace OpenSim.Grid.MessagingServer
  40. {
  41. public class MessageService
  42. {
  43. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  44. private MessageServerConfig m_cfg;
  45. //A hashtable of all current presences this server knows about
  46. private Hashtable m_presences = new Hashtable();
  47. //a hashtable of all current regions this server knows about
  48. private Hashtable m_regionInfoCache = new Hashtable();
  49. //A hashtable containing lists of UUIDs keyed by UUID for fast backreferencing
  50. private Hashtable m_presence_BackReferences = new Hashtable();
  51. // Hashtable containing work units that need to be processed
  52. private Hashtable m_unProcessedWorkUnits = new Hashtable();
  53. public MessageService(MessageServerConfig cfg)
  54. {
  55. m_cfg = cfg;
  56. }
  57. #region RegionComms Methods
  58. #endregion
  59. #region FriendList Methods
  60. /// <summary>
  61. /// Process Friendlist subscriptions for a user
  62. /// The login method calls this for a User
  63. /// </summary>
  64. /// <param name="userpresence">The Agent we're processing the friendlist subscriptions</param>
  65. public void ProcessFriendListSubscriptions(UserPresenceData userpresence)
  66. {
  67. lock (m_presences)
  68. {
  69. if (!m_presences.Contains(userpresence.agentData.AgentID))
  70. m_presences.Add(userpresence.agentData.AgentID, userpresence);
  71. }
  72. List<FriendListItem> uFriendList = userpresence.friendData;
  73. for (int i = 0; i < uFriendList.Count; i++)
  74. {
  75. //m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend);
  76. // m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID);
  77. if (m_presences.Contains(uFriendList[i].Friend))
  78. {
  79. UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i].Friend];
  80. // Add backreference
  81. SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i],i);
  82. }
  83. }
  84. }
  85. /// <summary>
  86. /// Does the necessary work to subscribe one agent to another's presence notifications
  87. /// Gets called by ProcessFriendListSubscriptions. You shouldn't call this directly
  88. /// unless you know what you're doing
  89. /// </summary>
  90. /// <param name="userpresence">P1</param>
  91. /// <param name="friendpresence">P2</param>
  92. /// <param name="uFriendListItem"></param>
  93. /// <param name="uFriendListIndex"></param>
  94. public void SubscribeToPresenceUpdates(UserPresenceData userpresence, UserPresenceData friendpresence,
  95. FriendListItem uFriendListItem, int uFriendListIndex)
  96. {
  97. if ((uFriendListItem.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
  98. {
  99. // Subscribe and Send Out updates
  100. if (!friendpresence.subscriptionData.Contains(friendpresence.agentData.AgentID))
  101. {
  102. userpresence.subscriptionData.Add(friendpresence.agentData.AgentID);
  103. //Send Region Notice....
  104. }
  105. else
  106. {
  107. // we need to send out online status update, but the user is already subscribed
  108. }
  109. PresenceInformer friendlistupdater = new PresenceInformer();
  110. friendlistupdater.presence1 = friendpresence;
  111. friendlistupdater.presence2 = userpresence;
  112. WaitCallback cb = new WaitCallback(friendlistupdater.go);
  113. ThreadPool.QueueUserWorkItem(cb);
  114. //SendRegionPresenceUpdate(friendpresence, userpresence);
  115. }
  116. if ((uFriendListItem.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
  117. {
  118. if (!friendpresence.subscriptionData.Contains(userpresence.agentData.AgentID))
  119. {
  120. friendpresence.subscriptionData.Add(userpresence.agentData.AgentID);
  121. //Send Region Notice....
  122. }
  123. else
  124. {
  125. // we need to send out online status update, but the user is already subscribed
  126. }
  127. PresenceInformer friendlistupdater = new PresenceInformer();
  128. friendlistupdater.presence1 = userpresence;
  129. friendlistupdater.presence2 = friendpresence;
  130. WaitCallback cb2 = new WaitCallback(friendlistupdater.go);
  131. ThreadPool.QueueUserWorkItem(cb2);
  132. //SendRegionPresenceUpdate(userpresence, friendpresence);
  133. }
  134. }
  135. /// <summary>
  136. /// Adds a backreference so presence specific data doesn't have to be
  137. /// enumerated for each logged in user every time someone logs on or off.
  138. /// </summary>
  139. /// <param name="agentID"></param>
  140. /// <param name="friendID"></param>
  141. public void addBackReference(LLUUID agentID, LLUUID friendID)
  142. {
  143. if (m_presence_BackReferences.Contains(friendID))
  144. {
  145. List<LLUUID> presenseBackReferences = (List<LLUUID>)m_presence_BackReferences[friendID];
  146. if (!presenseBackReferences.Contains(agentID))
  147. {
  148. presenseBackReferences.Add(agentID);
  149. }
  150. m_presence_BackReferences[friendID] = presenseBackReferences;
  151. }
  152. else
  153. {
  154. List<LLUUID> presenceBackReferences = new List<LLUUID>();
  155. presenceBackReferences.Add(agentID);
  156. m_presence_BackReferences[friendID] = presenceBackReferences;
  157. }
  158. }
  159. /// <summary>
  160. /// Removes a backreference to free up some memory
  161. /// </summary>
  162. /// <param name="agentID"></param>
  163. /// <param name="friendID"></param>
  164. public void removeBackReference(LLUUID agentID, LLUUID friendID)
  165. {
  166. if (m_presence_BackReferences.Contains(friendID))
  167. {
  168. List<LLUUID> presenseBackReferences = (List<LLUUID>)m_presence_BackReferences[friendID];
  169. if (presenseBackReferences.Contains(agentID))
  170. {
  171. presenseBackReferences.Remove(agentID);
  172. }
  173. // If there are no more backreferences for this agent,
  174. // remove it to free up memory.
  175. if (presenseBackReferences.Count == 0)
  176. {
  177. m_presence_BackReferences.Remove(agentID);
  178. }
  179. }
  180. }
  181. /// <summary>
  182. /// Logoff Processor. Call this to clean up agent presence data and send logoff presence notifications
  183. /// </summary>
  184. /// <param name="AgentID"></param>
  185. private void ProcessLogOff(LLUUID AgentID)
  186. {
  187. UserPresenceData AgentData = null;
  188. List<LLUUID> AgentsNeedingNotification = new List<LLUUID>();
  189. UserPresenceData friendd = null;
  190. lock (m_presences)
  191. {
  192. if (m_presences.Contains(AgentID))
  193. {
  194. AgentData = (UserPresenceData)m_presences[AgentID];
  195. }
  196. }
  197. if (AgentData != null)
  198. {
  199. AgentsNeedingNotification = AgentData.subscriptionData;
  200. //lock (m_presence_BackReferences)
  201. //{
  202. //if (m_presence_BackReferences.Contains(AgentID))
  203. //{
  204. //AgentsNeedingNotification = (List<LLUUID>)m_presence_BackReferences[AgentID];
  205. //}
  206. //}
  207. for (int i = 0; i < AgentsNeedingNotification.Count; i++)
  208. {
  209. // TODO: Do Region Notifications
  210. lock (m_presences)
  211. {
  212. if (m_presences.Contains(AgentsNeedingNotification[i]))
  213. {
  214. friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]];
  215. }
  216. }
  217. // This might need to be enumerated and checked before we try to remove it.
  218. if (friendd != null)
  219. {
  220. lock (friendd)
  221. {
  222. friendd.subscriptionData.Remove(AgentID);
  223. List<FriendListItem> fl = friendd.friendData;
  224. for (int j = 0; j < fl.Count; j++)
  225. {
  226. if (fl[j].Friend == AgentID)
  227. {
  228. fl[j].onlinestatus = false;
  229. }
  230. }
  231. friendd.friendData = fl;
  232. m_presences[AgentsNeedingNotification[i]] = friendd;
  233. }
  234. PresenceInformer friendlistupdater = new PresenceInformer();
  235. friendlistupdater.presence1 = AgentData;
  236. friendlistupdater.presence2 = friendd;
  237. WaitCallback cb3 = new WaitCallback(friendlistupdater.go);
  238. ThreadPool.QueueUserWorkItem(cb3);
  239. //SendRegionPresenceUpdate(AgentData, friendd);
  240. //removeBackReference(AgentID, AgentsNeedingNotification[i]);
  241. }
  242. }
  243. }
  244. }
  245. #endregion
  246. #region UserServer Comms
  247. /// <summary>
  248. /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner
  249. /// </summary>
  250. /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
  251. public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
  252. {
  253. List<FriendListItem> buddylist = new List<FriendListItem>();
  254. try
  255. {
  256. Hashtable param = new Hashtable();
  257. param["ownerID"] = friendlistowner.UUID.ToString();
  258. IList parameters = new ArrayList();
  259. parameters.Add(param);
  260. XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
  261. XmlRpcResponse resp = req.Send(m_cfg.UserServerURL, 3000);
  262. Hashtable respData = (Hashtable)resp.Value;
  263. if (respData.Contains("avcount"))
  264. {
  265. buddylist = ConvertXMLRPCDataToFriendListItemList(respData);
  266. }
  267. }
  268. catch (WebException e)
  269. {
  270. m_log.Warn("Error when trying to fetch Avatar's friends list: " +
  271. e.Message);
  272. // Return Empty list (no friends)
  273. }
  274. return buddylist;
  275. }
  276. /// <summary>
  277. /// Converts XMLRPC Friend List to FriendListItem Object
  278. /// </summary>
  279. /// <param name="data">XMLRPC response data Hashtable</param>
  280. /// <returns></returns>
  281. public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
  282. {
  283. List<FriendListItem> buddylist = new List<FriendListItem>();
  284. int buddycount = Convert.ToInt32((string)data["avcount"]);
  285. for (int i = 0; i < buddycount; i++)
  286. {
  287. FriendListItem buddylistitem = new FriendListItem();
  288. buddylistitem.FriendListOwner = new LLUUID((string)data["ownerID" + i.ToString()]);
  289. buddylistitem.Friend = new LLUUID((string)data["friendID" + i.ToString()]);
  290. buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]);
  291. buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]);
  292. buddylist.Add(buddylistitem);
  293. }
  294. return buddylist;
  295. }
  296. /// <summary>
  297. /// UserServer sends an expect_user method
  298. /// this handles the method and provisions the
  299. /// necessary info for presence to work
  300. /// </summary>
  301. /// <param name="request">UserServer Data</param>
  302. /// <returns></returns>
  303. public XmlRpcResponse UserLoggedOn(XmlRpcRequest request)
  304. {
  305. m_log.Info("[LOGON]: User logged on, building indexes for user");
  306. Hashtable requestData = (Hashtable)request.Params[0];
  307. //requestData["sendkey"] = serv.sendkey;
  308. //requestData["agentid"] = agentID.ToString();
  309. //requestData["sessionid"] = sessionID.ToString();
  310. //requestData["regionid"] = RegionID.ToString();
  311. //requestData["regionhandle"] = regionhandle.ToString();
  312. //requestData["positionx"] = positionX.ToString();
  313. //requestData["positiony"] = positionY.ToString();
  314. //requestData["positionz"] = positionZ.ToString();
  315. //requestData["firstname"] = firstname;
  316. //requestData["lastname"] = lastname;
  317. AgentCircuitData agentData = new AgentCircuitData();
  318. agentData.SessionID = new LLUUID((string)requestData["sessionid"]);
  319. agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
  320. agentData.firstname = (string)requestData["firstname"];
  321. agentData.lastname = (string)requestData["lastname"];
  322. agentData.AgentID = new LLUUID((string)requestData["agentid"]);
  323. agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
  324. agentData.CapsPath = (string)requestData["caps_path"];
  325. if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
  326. {
  327. agentData.child = true;
  328. }
  329. else
  330. {
  331. agentData.startpos =
  332. new LLVector3(Convert.ToUInt32(requestData["positionx"]),
  333. Convert.ToUInt32(requestData["positiony"]),
  334. Convert.ToUInt32(requestData["positionz"]));
  335. agentData.child = false;
  336. }
  337. ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
  338. UserPresenceData up = new UserPresenceData();
  339. up.agentData = agentData;
  340. List<FriendListItem> flData = GetUserFriendList(agentData.AgentID);
  341. up.friendData = flData;
  342. RegionProfileData riData = GetRegionInfo(regionHandle);
  343. up.regionData = riData;
  344. ProcessFriendListSubscriptions(up);
  345. return new XmlRpcResponse();
  346. }
  347. /// <summary>
  348. /// The UserServer got a Logoff message
  349. /// Cleanup time for that user. Send out presence notifications
  350. /// </summary>
  351. /// <param name="request"></param>
  352. /// <returns></returns>
  353. public XmlRpcResponse UserLoggedOff(XmlRpcRequest request)
  354. {
  355. Hashtable requestData = (Hashtable)request.Params[0];
  356. LLUUID AgentID = new LLUUID((string)requestData["agentid"]);
  357. ProcessLogOff(AgentID);
  358. return new XmlRpcResponse();
  359. }
  360. #endregion
  361. #region regioninfo gathering
  362. /// <summary>
  363. /// Gets and caches a RegionInfo object from the gridserver based on regionhandle
  364. /// if the regionhandle is already cached, use the cached values
  365. /// </summary>
  366. /// <param name="regionhandle">handle to the XY of the region we're looking for</param>
  367. /// <returns>A RegionInfo object to stick in the presence info</returns>
  368. public RegionProfileData GetRegionInfo(ulong regionhandle)
  369. {
  370. RegionProfileData regionInfo = null;
  371. if (m_regionInfoCache.Contains(regionhandle))
  372. {
  373. regionInfo = (RegionProfileData)m_regionInfoCache[regionhandle];
  374. }
  375. else
  376. {
  377. regionInfo = RequestRegionInfo(regionhandle);
  378. }
  379. return regionInfo;
  380. }
  381. /// <summary>
  382. /// Get RegionProfileData from the GridServer
  383. /// We'll Cache this information and use it for presence updates
  384. /// </summary>
  385. /// <param name="regionHandle"></param>
  386. /// <returns></returns>
  387. public RegionProfileData RequestRegionInfo(ulong regionHandle)
  388. { RegionProfileData regionProfile = null;
  389. try
  390. {
  391. Hashtable requestData = new Hashtable();
  392. requestData["region_handle"] = regionHandle.ToString();
  393. requestData["authkey"] = m_cfg.GridSendKey;
  394. ArrayList SendParams = new ArrayList();
  395. SendParams.Add(requestData);
  396. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
  397. XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000);
  398. Hashtable responseData = (Hashtable)GridResp.Value;
  399. if (responseData.ContainsKey("error"))
  400. {
  401. m_log.Error("[GRID]: error received from grid server" + responseData["error"]);
  402. return null;
  403. }
  404. uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
  405. uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
  406. string internalIpStr = (string)responseData["sim_ip"];
  407. uint port = Convert.ToUInt32(responseData["sim_port"]);
  408. string externalUri = (string)responseData["sim_uri"];
  409. string neighbourExternalUri = externalUri;
  410. regionProfile = new RegionProfileData();
  411. regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]);
  412. regionProfile.httpServerURI = "http://" + internalIpStr + ":" + regionProfile.httpPort + "/";
  413. regionProfile.regionHandle = Helpers.UIntsToLong((regX * Constants.RegionSize), (regY * Constants.RegionSize));
  414. regionProfile.regionLocX = regX;
  415. regionProfile.regionLocY = regY;
  416. regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
  417. regionProfile.UUID = new LLUUID((string)responseData["region_UUID"]);
  418. regionProfile.regionName = (string)responseData["region_name"];
  419. lock (m_regionInfoCache)
  420. {
  421. if (!m_regionInfoCache.Contains(regionHandle))
  422. {
  423. m_regionInfoCache.Add(regionHandle, regionProfile);
  424. }
  425. }
  426. }
  427. catch (WebException)
  428. {
  429. m_log.Error("[GRID]: " +
  430. "Region lookup failed for: " + regionHandle.ToString() +
  431. " - Is the GridServer down?");
  432. return null;
  433. }
  434. return regionProfile;
  435. }
  436. public bool registerWithUserServer ()
  437. {
  438. Hashtable UserParams = new Hashtable();
  439. // Login / Authentication
  440. if (m_cfg.HttpSSL)
  441. {
  442. UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
  443. }
  444. else
  445. {
  446. UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
  447. }
  448. UserParams["recvkey"] = m_cfg.UserRecvKey;
  449. UserParams["sendkey"] = m_cfg.UserRecvKey;
  450. // Package into an XMLRPC Request
  451. ArrayList SendParams = new ArrayList();
  452. SendParams.Add(UserParams);
  453. // Send Request
  454. XmlRpcRequest UserReq;
  455. XmlRpcResponse UserResp;
  456. try
  457. {
  458. UserReq = new XmlRpcRequest("register_messageserver", SendParams);
  459. UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
  460. } catch (Exception ex)
  461. {
  462. m_log.Error("Unable to connect to grid. Grid server not running?");
  463. throw(ex);
  464. }
  465. Hashtable GridRespData = (Hashtable)UserResp.Value;
  466. Hashtable griddatahash = GridRespData;
  467. // Process Response
  468. if (GridRespData.ContainsKey("responsestring"))
  469. {
  470. return true;
  471. }
  472. else
  473. {
  474. return false;
  475. }
  476. }
  477. public bool deregisterWithUserServer()
  478. {
  479. Hashtable UserParams = new Hashtable();
  480. // Login / Authentication
  481. if (m_cfg.HttpSSL)
  482. {
  483. UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
  484. }
  485. else
  486. {
  487. UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort;
  488. }
  489. UserParams["recvkey"] = m_cfg.UserRecvKey;
  490. UserParams["sendkey"] = m_cfg.UserRecvKey;
  491. // Package into an XMLRPC Request
  492. ArrayList SendParams = new ArrayList();
  493. SendParams.Add(UserParams);
  494. // Send Request
  495. XmlRpcRequest UserReq;
  496. XmlRpcResponse UserResp;
  497. try
  498. {
  499. UserReq = new XmlRpcRequest("deregister_messageserver", SendParams);
  500. UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
  501. }
  502. catch (Exception ex)
  503. {
  504. m_log.Error("Unable to connect to grid. Grid server not running?");
  505. throw (ex);
  506. }
  507. Hashtable UserRespData = (Hashtable)UserResp.Value;
  508. Hashtable userdatahash = UserRespData;
  509. // Process Response
  510. if (UserRespData.ContainsKey("responsestring"))
  511. {
  512. return true;
  513. }
  514. else
  515. {
  516. return false;
  517. }
  518. }
  519. #endregion
  520. }
  521. }