SceneCommunicationService.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  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.Generic;
  29. using System.Net;
  30. using System.Reflection;
  31. using System.Threading;
  32. using OpenMetaverse;
  33. using OpenMetaverse.StructuredData;
  34. using log4net;
  35. using OpenSim.Region.Environment.Interfaces;
  36. using OpenSim.Framework;
  37. using OpenSim.Framework.Communications;
  38. using OpenSim.Framework.Communications.Capabilities;
  39. using OpenSim.Region.Interfaces;
  40. using OSD = OpenMetaverse.StructuredData.OSD;
  41. namespace OpenSim.Region.Environment.Scenes
  42. {
  43. public delegate void KiPrimitiveDelegate(uint localID);
  44. public delegate void RemoveKnownRegionsFromAvatarList(UUID avatarID, List<ulong> regionlst);
  45. public class SceneCommunicationService //one instance per region
  46. {
  47. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  48. protected CommunicationsManager m_commsProvider;
  49. protected IInterregionCommsOut m_interregionCommsOut;
  50. protected RegionInfo m_regionInfo;
  51. protected RegionCommsListener regionCommsHost;
  52. protected List<UUID> m_agentsInTransit;
  53. public event AgentCrossing OnAvatarCrossingIntoRegion;
  54. public event ExpectUserDelegate OnExpectUser;
  55. public event ExpectPrimDelegate OnExpectPrim;
  56. public event CloseAgentConnection OnCloseAgentConnection;
  57. public event PrimCrossing OnPrimCrossingIntoRegion;
  58. public event RegionUp OnRegionUp;
  59. public event ChildAgentUpdate OnChildAgentUpdate;
  60. //public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar;
  61. public event LogOffUser OnLogOffUser;
  62. public event GetLandData OnGetLandData;
  63. private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
  64. private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
  65. private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
  66. private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
  67. private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
  68. private RegionUp handlerRegionUp = null; // OnRegionUp;
  69. private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
  70. //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
  71. private LogOffUser handlerLogOffUser = null;
  72. private GetLandData handlerGetLandData = null; // OnGetLandData
  73. public KiPrimitiveDelegate KiPrimitive;
  74. public SceneCommunicationService(CommunicationsManager commsMan)
  75. {
  76. m_commsProvider = commsMan;
  77. m_agentsInTransit = new List<UUID>();
  78. }
  79. /// <summary>
  80. /// Register a region with the grid
  81. /// </summary>
  82. /// <param name="regionInfos"></param>
  83. /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
  84. public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
  85. {
  86. m_interregionCommsOut = comms_out;
  87. m_regionInfo = regionInfos;
  88. m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
  89. m_commsProvider.InterRegion.rdebugRegionName = regionInfos.RegionName;
  90. regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
  91. if (regionCommsHost != null)
  92. {
  93. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
  94. regionCommsHost.debugRegionName = regionInfos.RegionName;
  95. regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
  96. regionCommsHost.OnExpectUser += NewUserConnection;
  97. regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
  98. regionCommsHost.OnCloseAgentConnection += CloseConnection;
  99. regionCommsHost.OnRegionUp += newRegionUp;
  100. regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
  101. regionCommsHost.OnLogOffUser += GridLogOffUser;
  102. regionCommsHost.OnGetLandData += FetchLandData;
  103. }
  104. else
  105. {
  106. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
  107. }
  108. }
  109. public RegionInfo RequestClosestRegion(string name)
  110. {
  111. return m_commsProvider.GridService.RequestClosestRegion(name);
  112. }
  113. public void Close()
  114. {
  115. if (regionCommsHost != null)
  116. {
  117. regionCommsHost.OnLogOffUser -= GridLogOffUser;
  118. regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
  119. regionCommsHost.OnRegionUp -= newRegionUp;
  120. regionCommsHost.OnExpectUser -= NewUserConnection;
  121. regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
  122. regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
  123. regionCommsHost.OnCloseAgentConnection -= CloseConnection;
  124. regionCommsHost.OnGetLandData -= FetchLandData;
  125. try
  126. {
  127. m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
  128. }
  129. catch (Exception e)
  130. {
  131. m_log.ErrorFormat(
  132. "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
  133. m_regionInfo.RegionName, e);
  134. }
  135. regionCommsHost = null;
  136. }
  137. }
  138. #region CommsManager Event handlers
  139. /// <summary>
  140. ///
  141. /// </summary>
  142. /// <param name="regionHandle"></param>
  143. /// <param name="agent"></param>
  144. ///
  145. protected void NewUserConnection(AgentCircuitData agent)
  146. {
  147. handlerExpectUser = OnExpectUser;
  148. if (handlerExpectUser != null)
  149. {
  150. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
  151. handlerExpectUser(agent);
  152. }
  153. }
  154. protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message)
  155. {
  156. handlerLogOffUser = OnLogOffUser;
  157. if (handlerLogOffUser != null)
  158. {
  159. handlerLogOffUser(AgentID, RegionSecret, message);
  160. }
  161. }
  162. protected bool newRegionUp(RegionInfo region)
  163. {
  164. handlerRegionUp = OnRegionUp;
  165. if (handlerRegionUp != null)
  166. {
  167. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
  168. handlerRegionUp(region);
  169. }
  170. return true;
  171. }
  172. protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData)
  173. {
  174. handlerChildAgentUpdate = OnChildAgentUpdate;
  175. if (handlerChildAgentUpdate != null)
  176. handlerChildAgentUpdate(cAgentData);
  177. return true;
  178. }
  179. protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
  180. {
  181. handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
  182. if (handlerAvatarCrossingIntoRegion != null)
  183. {
  184. handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
  185. }
  186. }
  187. protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod)
  188. {
  189. handlerExpectPrim = OnExpectPrim;
  190. if (handlerExpectPrim != null)
  191. {
  192. return handlerExpectPrim(primID, objXMLData, XMLMethod);
  193. }
  194. else
  195. {
  196. return false;
  197. }
  198. }
  199. protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
  200. {
  201. handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
  202. if (handlerPrimCrossingIntoRegion != null)
  203. {
  204. handlerPrimCrossingIntoRegion(primID, position, isPhysical);
  205. }
  206. }
  207. protected bool CloseConnection(UUID agentID)
  208. {
  209. m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
  210. handlerCloseAgentConnection = OnCloseAgentConnection;
  211. if (handlerCloseAgentConnection != null)
  212. {
  213. return handlerCloseAgentConnection(agentID);
  214. }
  215. return false;
  216. }
  217. protected LandData FetchLandData(uint x, uint y)
  218. {
  219. handlerGetLandData = OnGetLandData;
  220. if (handlerGetLandData != null)
  221. {
  222. return handlerGetLandData(x, y);
  223. }
  224. return null;
  225. }
  226. #endregion
  227. #region Inform Client of Neighbours
  228. private delegate void InformClientOfNeighbourDelegate(
  229. ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent);
  230. private void InformClientOfNeighbourCompleted(IAsyncResult iar)
  231. {
  232. InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
  233. icon.EndInvoke(iar);
  234. }
  235. /// <summary>
  236. /// Async component for informing client of which neighbours exist
  237. /// </summary>
  238. /// <remarks>
  239. /// This needs to run asynchronesously, as a network timeout may block the thread for a long while
  240. /// </remarks>
  241. /// <param name="remoteClient"></param>
  242. /// <param name="a"></param>
  243. /// <param name="regionHandle"></param>
  244. /// <param name="endPoint"></param>
  245. private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg,
  246. IPEndPoint endPoint, bool newAgent)
  247. {
  248. // Let's wait just a little to give time to originating regions to catch up with closing child agents
  249. // after a cross here
  250. Thread.Sleep(500);
  251. uint x, y;
  252. Utils.LongToUInts(reg.RegionHandle, out x, out y);
  253. x = x / Constants.RegionSize;
  254. y = y / Constants.RegionSize;
  255. m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
  256. string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
  257. + "/CAPS/" + a.CapsPath + "0000/";
  258. //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
  259. bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a);
  260. if (regionAccepted && newAgent)
  261. {
  262. IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
  263. if (eq != null)
  264. {
  265. OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, endPoint);
  266. eq.Enqueue(Item, avatar.UUID);
  267. Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, endPoint.ToString(), capsPath);
  268. eq.Enqueue(Item, avatar.UUID);
  269. m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
  270. }
  271. else
  272. {
  273. avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
  274. // TODO: make Event Queue disablable!
  275. }
  276. m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
  277. }
  278. }
  279. public void RequestNeighbors(RegionInfo region)
  280. {
  281. // List<SimpleRegionInfo> neighbours =
  282. m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
  283. //IPEndPoint blah = new IPEndPoint();
  284. //blah.Address = region.RemotingAddress;
  285. //blah.Port = region.RemotingPort;
  286. }
  287. /// <summary>
  288. /// This informs all neighboring regions about agent "avatar".
  289. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
  290. /// </summary>
  291. public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
  292. {
  293. List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
  294. //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
  295. for (int i = 0; i < lstneighbours.Count; i++)
  296. {
  297. // We don't want to keep sending to regions that consistently fail on comms.
  298. if (!(lstneighbours[i].commFailTF))
  299. {
  300. neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
  301. }
  302. }
  303. // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
  304. // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
  305. neighbours =
  306. m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
  307. /// We need to find the difference between the new regions where there are no child agents
  308. /// and the regions where there are already child agents. We only send notification to the former.
  309. List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
  310. neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
  311. List<ulong> previousRegionNeighbourHandles = new List<ulong>(avatar.Scene.GetChildrenSeeds(avatar.UUID).Keys);
  312. List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
  313. List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
  314. //Dump("Current Neighbors", neighbourHandles);
  315. //Dump("Previous Neighbours", previousRegionNeighbourHandles);
  316. //Dump("New Neighbours", newRegions);
  317. //Dump("Old Neighbours", oldRegions);
  318. /// Update the scene presence's known regions here on this region
  319. avatar.DropOldNeighbours(oldRegions);
  320. /// Collect as many seeds as possible
  321. Dictionary<ulong, string> seeds = new Dictionary<ulong, string>(avatar.Scene.GetChildrenSeeds(avatar.UUID));
  322. //Console.WriteLine(" !!! No. of seeds: " + seeds.Count);
  323. if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
  324. seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
  325. /// Create the necessary child agents
  326. List<AgentCircuitData> cagents = new List<AgentCircuitData>();
  327. foreach (SimpleRegionInfo neighbour in neighbours)
  328. {
  329. if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
  330. {
  331. AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
  332. agent.BaseFolder = UUID.Zero;
  333. agent.InventoryFolder = UUID.Zero;
  334. agent.startpos = new Vector3(128, 128, 70);
  335. agent.child = true;
  336. if (newRegions.Contains(neighbour.RegionHandle))
  337. {
  338. agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
  339. avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
  340. seeds.Add(neighbour.RegionHandle, agent.CapsPath);
  341. }
  342. else
  343. agent.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
  344. cagents.Add(agent);
  345. }
  346. }
  347. /// Update all child agent with everyone's seeds
  348. foreach (AgentCircuitData a in cagents)
  349. {
  350. a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
  351. }
  352. // These two are the same thing!
  353. avatar.Scene.SetChildrenSeed(avatar.UUID, seeds);
  354. avatar.KnownRegions = seeds;
  355. //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
  356. //avatar.DumpKnownRegions();
  357. bool newAgent = false;
  358. int count = 0;
  359. foreach (SimpleRegionInfo neighbour in neighbours)
  360. {
  361. // Don't do it if there's already an agent in that region
  362. if (newRegions.Contains(neighbour.RegionHandle))
  363. newAgent = true;
  364. else
  365. newAgent = false;
  366. if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
  367. {
  368. InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
  369. try
  370. {
  371. d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
  372. InformClientOfNeighbourCompleted,
  373. d);
  374. }
  375. catch (Exception e)
  376. {
  377. m_log.ErrorFormat(
  378. "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
  379. neighbour.ExternalHostName,
  380. neighbour.RegionHandle,
  381. neighbour.RegionLocX,
  382. neighbour.RegionLocY,
  383. e);
  384. // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
  385. // since I don't know what will happen if we just let the client continue
  386. // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
  387. // throw e;
  388. }
  389. }
  390. count++;
  391. }
  392. }
  393. /// <summary>
  394. /// This informs a single neighboring region about agent "avatar".
  395. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
  396. /// </summary>
  397. public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region, List<RegionInfo> neighbours)
  398. {
  399. AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
  400. agent.BaseFolder = UUID.Zero;
  401. agent.InventoryFolder = UUID.Zero;
  402. agent.startpos = new Vector3(128, 128, 70);
  403. agent.child = true;
  404. InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
  405. d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
  406. InformClientOfNeighbourCompleted,
  407. d);
  408. }
  409. #endregion
  410. public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle);
  411. private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
  412. {
  413. InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState;
  414. icon.EndInvoke(iar);
  415. }
  416. /// <summary>
  417. /// Asynchronous call to information neighbouring regions that this region is up
  418. /// </summary>
  419. /// <param name="region"></param>
  420. /// <param name="regionhandle"></param>
  421. private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle)
  422. {
  423. m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here");
  424. //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port);
  425. bool regionAccepted =
  426. m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
  427. if (regionAccepted)
  428. {
  429. m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here");
  430. handlerRegionUp = OnRegionUp;
  431. // yes, we're notifying ourselves.
  432. if (handlerRegionUp != null)
  433. handlerRegionUp(region);
  434. }
  435. else
  436. {
  437. m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here.");
  438. }
  439. }
  440. /// <summary>
  441. /// Called by scene when region is initialized (not always when it's listening for agents)
  442. /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
  443. /// </summary>
  444. public void InformNeighborsThatRegionisUp(RegionInfo region)
  445. {
  446. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
  447. List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
  448. // This stays uncached because we don't already know about our neighbors at this point.
  449. neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
  450. if (neighbours != null)
  451. {
  452. for (int i = 0; i < neighbours.Count; i++)
  453. {
  454. InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
  455. d.BeginInvoke(region, neighbours[i].RegionHandle,
  456. InformNeighborsThatRegionisUpCompleted,
  457. d);
  458. }
  459. }
  460. //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
  461. }
  462. public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
  463. /// <summary>
  464. /// This informs all neighboring regions about the settings of it's child agent.
  465. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
  466. ///
  467. /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc.
  468. ///
  469. /// </summary>
  470. private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, ulong regionHandle)
  471. {
  472. //m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + m_regionInfo.RegionName);
  473. try
  474. {
  475. //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
  476. m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData);
  477. }
  478. catch
  479. {
  480. // Ignore; we did our best
  481. }
  482. //if (regionAccepted)
  483. //{
  484. // //m_log.Info("[INTERGRID]: Completed sending a neighbor an update about my agent");
  485. //}
  486. //else
  487. //{
  488. // //m_log.Info("[INTERGRID]: Failed sending a neighbor an update about my agent");
  489. //}
  490. }
  491. private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
  492. {
  493. SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate) iar.AsyncState;
  494. icon.EndInvoke(iar);
  495. }
  496. public void SendChildAgentDataUpdate(AgentPosition cAgentData, ScenePresence presence)
  497. {
  498. // This assumes that we know what our neighbors are.
  499. try
  500. {
  501. foreach (ulong regionHandle in presence.KnownChildRegionHandles)
  502. {
  503. if (regionHandle != m_regionInfo.RegionHandle)
  504. {
  505. SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync;
  506. d.BeginInvoke(cAgentData, regionHandle,
  507. SendChildAgentDataUpdateCompleted,
  508. d);
  509. }
  510. }
  511. }
  512. catch (InvalidOperationException)
  513. {
  514. // We're ignoring a collection was modified error because this data gets old and outdated fast.
  515. }
  516. }
  517. public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle);
  518. /// <summary>
  519. /// This Closes child agents on neighboring regions
  520. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
  521. /// </summary>
  522. protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle)
  523. {
  524. m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle);
  525. // let's do our best, but there's not much we can do if the neighbour doesn't accept.
  526. //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
  527. m_interregionCommsOut.SendCloseAgent(regionHandle, agentID);
  528. }
  529. private void SendCloseChildAgentCompleted(IAsyncResult iar)
  530. {
  531. SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState;
  532. icon.EndInvoke(iar);
  533. }
  534. public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst)
  535. {
  536. foreach (ulong handle in regionslst)
  537. {
  538. SendCloseChildAgentDelegate d = SendCloseChildAgentAsync;
  539. d.BeginInvoke(agentID, handle,
  540. SendCloseChildAgentCompleted,
  541. d);
  542. }
  543. }
  544. /// <summary>
  545. /// Helper function to request neighbors from grid-comms
  546. /// </summary>
  547. /// <param name="regionHandle"></param>
  548. /// <returns></returns>
  549. public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
  550. {
  551. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
  552. return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
  553. }
  554. /// <summary>
  555. /// Helper function to request neighbors from grid-comms
  556. /// </summary>
  557. /// <param name="regionID"></param>
  558. /// <returns></returns>
  559. public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
  560. {
  561. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
  562. return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
  563. }
  564. /// <summary>
  565. /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
  566. /// </summary>
  567. /// <param name="minX"></param>
  568. /// <param name="minY"></param>
  569. /// <param name="maxX"></param>
  570. /// <param name="maxY"></param>
  571. public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
  572. {
  573. List<MapBlockData> mapBlocks;
  574. mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
  575. remoteClient.SendMapBlock(mapBlocks, 0);
  576. }
  577. /// <summary>
  578. /// Try to teleport an agent to a new region.
  579. /// </summary>
  580. /// <param name="remoteClient"></param>
  581. /// <param name="RegionHandle"></param>
  582. /// <param name="position"></param>
  583. /// <param name="lookAt"></param>
  584. /// <param name="flags"></param>
  585. public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
  586. Vector3 lookAt, uint teleportFlags)
  587. {
  588. m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} ", position.ToString());
  589. if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
  590. return;
  591. bool destRegionUp = false;
  592. IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
  593. if (regionHandle == m_regionInfo.RegionHandle)
  594. {
  595. // Teleport within the same region
  596. if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0)
  597. {
  598. Vector3 emergencyPos = new Vector3(128, 128, 128);
  599. m_log.WarnFormat(
  600. "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
  601. position, avatar.Name, avatar.UUID, emergencyPos);
  602. position = emergencyPos;
  603. }
  604. // TODO: Get proper AVG Height
  605. float localAVHeight = 1.56f;
  606. float posZLimit = (float)avatar.Scene.GetLandHeight((int)position.X, (int)position.Y);
  607. float newPosZ = posZLimit + localAVHeight;
  608. if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
  609. {
  610. position.Z = newPosZ;
  611. }
  612. // Only send this if the event queue is null
  613. if (eq == null)
  614. avatar.ControllingClient.SendTeleportLocationStart();
  615. avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
  616. avatar.Teleport(position);
  617. }
  618. else
  619. {
  620. RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
  621. if (reg != null)
  622. {
  623. if (eq == null)
  624. avatar.ControllingClient.SendTeleportLocationStart();
  625. if (reg.RemotingAddress != "" && reg.RemotingPort != 0)
  626. {
  627. // region is remote. see if it is up
  628. destRegionUp = m_commsProvider.InterRegion.CheckRegion(reg.RemotingAddress, reg.RemotingPort);
  629. }
  630. else
  631. {
  632. // assume local regions are always up
  633. destRegionUp = true;
  634. }
  635. // Let's do DNS resolution only once in this process, please!
  636. // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
  637. // it's actually doing a lot of work.
  638. IPEndPoint endPoint = reg.ExternalEndPoint;
  639. if (endPoint.Address == null)
  640. {
  641. // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
  642. destRegionUp = false;
  643. }
  644. if (destRegionUp)
  645. {
  646. uint newRegionX = (uint)(reg.RegionHandle >> 40);
  647. uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
  648. uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
  649. uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
  650. // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
  651. // both regions
  652. if (avatar.ParentID != (uint)0)
  653. avatar.StandUp();
  654. if (!avatar.ValidateAttachments())
  655. {
  656. avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
  657. return;
  658. }
  659. // the avatar.Close below will clear the child region list. We need this below for (possibly)
  660. // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
  661. //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
  662. // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
  663. // failure at this point (unlike a border crossing failure). So perhaps this can never fail
  664. // once we reach here...
  665. //avatar.Scene.RemoveCapsHandler(avatar.UUID);
  666. string capsPath = String.Empty;
  667. AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
  668. agentCircuit.BaseFolder = UUID.Zero;
  669. agentCircuit.InventoryFolder = UUID.Zero;
  670. agentCircuit.startpos = position;
  671. agentCircuit.child = true;
  672. if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
  673. {
  674. // brand new agent, let's create a new caps seed
  675. agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
  676. }
  677. // Let's create an agent there if one doesn't exist yet.
  678. //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
  679. if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit))
  680. {
  681. avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports.");
  682. return;
  683. }
  684. // OK, it got this agent. Let's close some child agents
  685. avatar.CloseChildAgents(newRegionX, newRegionY);
  686. if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
  687. {
  688. capsPath
  689. = "http://"
  690. + reg.ExternalHostName
  691. + ":"
  692. + reg.HttpPort
  693. + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
  694. if (eq != null)
  695. {
  696. OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, endPoint);
  697. eq.Enqueue(Item, avatar.UUID);
  698. // ES makes the client send a UseCircuitCode message to the destination,
  699. // which triggers a bunch of things there.
  700. // So let's wait
  701. Thread.Sleep(2000);
  702. Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, endPoint.ToString(), capsPath);
  703. eq.Enqueue(Item, avatar.UUID);
  704. }
  705. else
  706. {
  707. avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
  708. }
  709. }
  710. else
  711. {
  712. agentCircuit.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle);
  713. capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
  714. + "/CAPS/" + agentCircuit.CapsPath + "0000/";
  715. }
  716. // Expect avatar crossing is a heavy-duty function at the destination.
  717. // That is where MakeRoot is called, which fetches appearance and inventory.
  718. // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
  719. //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
  720. // position, false);
  721. //{
  722. // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
  723. // // We should close that agent we just created over at destination...
  724. // List<ulong> lst = new List<ulong>();
  725. // lst.Add(reg.RegionHandle);
  726. // SendCloseChildAgentAsync(avatar.UUID, lst);
  727. // return;
  728. //}
  729. SetInTransit(avatar.UUID);
  730. // Let's send a full update of the agent. This is a synchronous call.
  731. AgentData agent = new AgentData();
  732. avatar.CopyTo(agent);
  733. agent.Position = position;
  734. agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
  735. "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
  736. m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
  737. m_log.DebugFormat(
  738. "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
  739. if (eq != null)
  740. {
  741. OSD Item = EventQueueHelper.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
  742. 4, teleportFlags, capsPath, avatar.UUID);
  743. eq.Enqueue(Item, avatar.UUID);
  744. }
  745. else
  746. {
  747. avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
  748. teleportFlags, capsPath);
  749. }
  750. // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
  751. // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
  752. // that the client contacted the destination before we send the attachments and close things here.
  753. if (!WaitForCallback(avatar.UUID))
  754. {
  755. // Client never contacted destination. Let's restore everything back
  756. avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
  757. ResetFromTransit(avatar.UUID);
  758. // Yikes! We should just have a ref to scene here.
  759. avatar.Scene.InformClientOfNeighbours(avatar);
  760. // Finally, kill the agent we just created at the destination.
  761. m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
  762. return;
  763. }
  764. // Can't go back from here
  765. if (KiPrimitive != null)
  766. {
  767. KiPrimitive(avatar.LocalId);
  768. }
  769. avatar.MakeChildAgent();
  770. // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
  771. avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
  772. // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
  773. if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
  774. {
  775. Thread.Sleep(5000);
  776. avatar.Close();
  777. CloseConnection(avatar.UUID);
  778. }
  779. // if (teleport success) // seems to be always success here
  780. // the user may change their profile information in other region,
  781. // so the userinfo in UserProfileCache is not reliable any more, delete it
  782. if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
  783. {
  784. m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
  785. m_log.DebugFormat(
  786. "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
  787. avatar.UUID);
  788. }
  789. }
  790. else
  791. {
  792. avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
  793. }
  794. }
  795. else
  796. {
  797. // TP to a place that doesn't exist (anymore)
  798. // Inform the viewer about that
  799. avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
  800. // and set the map-tile to '(Offline)'
  801. uint regX, regY;
  802. Utils.LongToUInts(regionHandle, out regX, out regY);
  803. MapBlockData block = new MapBlockData();
  804. block.X = (ushort)(regX / Constants.RegionSize);
  805. block.Y = (ushort)(regY / Constants.RegionSize);
  806. block.Access = 254; // == not there
  807. List<MapBlockData> blocks = new List<MapBlockData>();
  808. blocks.Add(block);
  809. avatar.ControllingClient.SendMapBlock(blocks, 0);
  810. }
  811. }
  812. }
  813. protected bool WaitForCallback(UUID id)
  814. {
  815. int count = 20;
  816. while (m_agentsInTransit.Contains(id) && count-- > 0)
  817. {
  818. //Console.WriteLine(" >>> Waiting... " + count);
  819. Thread.Sleep(1000);
  820. }
  821. if (count > 0)
  822. return true;
  823. else
  824. return false;
  825. }
  826. public bool ReleaseAgent(UUID id)
  827. {
  828. //Console.WriteLine(" >>> ReleaseAgent called <<< ");
  829. return ResetFromTransit(id);
  830. }
  831. protected void SetInTransit(UUID id)
  832. {
  833. lock (m_agentsInTransit)
  834. {
  835. if (!m_agentsInTransit.Contains(id))
  836. m_agentsInTransit.Add(id);
  837. }
  838. }
  839. protected bool ResetFromTransit(UUID id)
  840. {
  841. lock (m_agentsInTransit)
  842. {
  843. if (m_agentsInTransit.Contains(id))
  844. {
  845. m_agentsInTransit.Remove(id);
  846. return true;
  847. }
  848. }
  849. return false;
  850. }
  851. private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours)
  852. {
  853. List<ulong> handles = new List<ulong>();
  854. foreach (SimpleRegionInfo reg in neighbours)
  855. {
  856. handles.Add(reg.RegionHandle);
  857. }
  858. return handles;
  859. }
  860. private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
  861. {
  862. return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
  863. }
  864. // private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
  865. // {
  866. // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
  867. // }
  868. private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
  869. {
  870. return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
  871. }
  872. /// <summary>
  873. /// Inform a neighbouring region that an avatar is about to cross into it.
  874. /// </summary>
  875. /// <param name="regionhandle"></param>
  876. /// <param name="agentID"></param>
  877. /// <param name="position"></param>
  878. public bool CrossToNeighbouringRegion(ulong regionhandle, UUID agentID, Vector3 position, bool isFlying)
  879. {
  880. return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying);
  881. }
  882. public bool PrimCrossToNeighboringRegion(ulong regionhandle, UUID primID, string objData, int XMLMethod)
  883. {
  884. return m_commsProvider.InterRegion.InformRegionOfPrimCrossing(regionhandle, primID, objData, XMLMethod);
  885. }
  886. public Dictionary<string, string> GetGridSettings()
  887. {
  888. return m_commsProvider.GridService.GetGridSettings();
  889. }
  890. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
  891. {
  892. m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
  893. }
  894. // deprecated as of 2008-08-27
  895. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
  896. {
  897. m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
  898. }
  899. public void ClearUserAgent(UUID avatarID)
  900. {
  901. m_commsProvider.UserService.ClearUserAgent(avatarID);
  902. }
  903. public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
  904. {
  905. m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
  906. }
  907. public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
  908. {
  909. m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
  910. }
  911. public void RemoveUserFriend(UUID friendlistowner, UUID friend)
  912. {
  913. m_commsProvider.RemoveUserFriend(friendlistowner, friend);
  914. }
  915. public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
  916. {
  917. return m_commsProvider.GetUserFriendList(friendlistowner);
  918. }
  919. public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
  920. {
  921. return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
  922. }
  923. public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
  924. {
  925. return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
  926. }
  927. public List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
  928. {
  929. return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
  930. }
  931. // private void Dump(string msg, List<ulong> handles)
  932. // {
  933. // Console.WriteLine("-------------- HANDLE DUMP ({0}) ---------", msg);
  934. // foreach (ulong handle in handles)
  935. // {
  936. // uint x, y;
  937. // Utils.LongToUInts(handle, out x, out y);
  938. // x = x / Constants.RegionSize;
  939. // y = y / Constants.RegionSize;
  940. // Console.WriteLine("({0}, {1})", x, y);
  941. // }
  942. // }
  943. }
  944. }