SceneCommunicationService.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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
  312. = new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
  313. List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
  314. List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
  315. //Dump("Current Neighbors", neighbourHandles);
  316. //Dump("Previous Neighbours", previousRegionNeighbourHandles);
  317. //Dump("New Neighbours", newRegions);
  318. //Dump("Old Neighbours", oldRegions);
  319. /// Update the scene presence's known regions here on this region
  320. avatar.DropOldNeighbours(oldRegions);
  321. /// Collect as many seeds as possible
  322. Dictionary<ulong, string> seeds
  323. = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
  324. //Console.WriteLine(" !!! No. of seeds: " + seeds.Count);
  325. if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
  326. seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
  327. /// Create the necessary child agents
  328. List<AgentCircuitData> cagents = new List<AgentCircuitData>();
  329. foreach (SimpleRegionInfo neighbour in neighbours)
  330. {
  331. if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
  332. {
  333. AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
  334. agent.BaseFolder = UUID.Zero;
  335. agent.InventoryFolder = UUID.Zero;
  336. agent.startpos = new Vector3(128, 128, 70);
  337. agent.child = true;
  338. if (newRegions.Contains(neighbour.RegionHandle))
  339. {
  340. agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
  341. avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
  342. seeds.Add(neighbour.RegionHandle, agent.CapsPath);
  343. }
  344. else
  345. agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
  346. cagents.Add(agent);
  347. }
  348. }
  349. /// Update all child agent with everyone's seeds
  350. foreach (AgentCircuitData a in cagents)
  351. {
  352. a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
  353. }
  354. // These two are the same thing!
  355. avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
  356. avatar.KnownRegions = seeds;
  357. //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
  358. //avatar.DumpKnownRegions();
  359. bool newAgent = false;
  360. int count = 0;
  361. foreach (SimpleRegionInfo neighbour in neighbours)
  362. {
  363. // Don't do it if there's already an agent in that region
  364. if (newRegions.Contains(neighbour.RegionHandle))
  365. newAgent = true;
  366. else
  367. newAgent = false;
  368. if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
  369. {
  370. InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
  371. try
  372. {
  373. d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
  374. InformClientOfNeighbourCompleted,
  375. d);
  376. }
  377. catch (Exception e)
  378. {
  379. m_log.ErrorFormat(
  380. "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
  381. neighbour.ExternalHostName,
  382. neighbour.RegionHandle,
  383. neighbour.RegionLocX,
  384. neighbour.RegionLocY,
  385. e);
  386. // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
  387. // since I don't know what will happen if we just let the client continue
  388. // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
  389. // throw e;
  390. }
  391. }
  392. count++;
  393. }
  394. }
  395. /// <summary>
  396. /// This informs a single neighboring region about agent "avatar".
  397. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
  398. /// </summary>
  399. public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region, List<RegionInfo> neighbours)
  400. {
  401. AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
  402. agent.BaseFolder = UUID.Zero;
  403. agent.InventoryFolder = UUID.Zero;
  404. agent.startpos = new Vector3(128, 128, 70);
  405. agent.child = true;
  406. InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
  407. d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
  408. InformClientOfNeighbourCompleted,
  409. d);
  410. }
  411. #endregion
  412. public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle);
  413. private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
  414. {
  415. InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState;
  416. icon.EndInvoke(iar);
  417. }
  418. /// <summary>
  419. /// Asynchronous call to information neighbouring regions that this region is up
  420. /// </summary>
  421. /// <param name="region"></param>
  422. /// <param name="regionhandle"></param>
  423. private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle)
  424. {
  425. m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here");
  426. //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port);
  427. bool regionAccepted =
  428. m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
  429. if (regionAccepted)
  430. {
  431. m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here");
  432. handlerRegionUp = OnRegionUp;
  433. // yes, we're notifying ourselves.
  434. if (handlerRegionUp != null)
  435. handlerRegionUp(region);
  436. }
  437. else
  438. {
  439. m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here.");
  440. }
  441. }
  442. /// <summary>
  443. /// Called by scene when region is initialized (not always when it's listening for agents)
  444. /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
  445. /// </summary>
  446. public void InformNeighborsThatRegionisUp(RegionInfo region)
  447. {
  448. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
  449. List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
  450. // This stays uncached because we don't already know about our neighbors at this point.
  451. neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
  452. if (neighbours != null)
  453. {
  454. for (int i = 0; i < neighbours.Count; i++)
  455. {
  456. InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
  457. d.BeginInvoke(region, neighbours[i].RegionHandle,
  458. InformNeighborsThatRegionisUpCompleted,
  459. d);
  460. }
  461. }
  462. //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
  463. }
  464. public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
  465. /// <summary>
  466. /// This informs all neighboring regions about the settings of it's child agent.
  467. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
  468. ///
  469. /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc.
  470. ///
  471. /// </summary>
  472. private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, ulong regionHandle)
  473. {
  474. //m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + m_regionInfo.RegionName);
  475. try
  476. {
  477. //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
  478. m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData);
  479. }
  480. catch
  481. {
  482. // Ignore; we did our best
  483. }
  484. //if (regionAccepted)
  485. //{
  486. // //m_log.Info("[INTERGRID]: Completed sending a neighbor an update about my agent");
  487. //}
  488. //else
  489. //{
  490. // //m_log.Info("[INTERGRID]: Failed sending a neighbor an update about my agent");
  491. //}
  492. }
  493. private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
  494. {
  495. SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate) iar.AsyncState;
  496. icon.EndInvoke(iar);
  497. }
  498. public void SendChildAgentDataUpdate(AgentPosition cAgentData, ScenePresence presence)
  499. {
  500. // This assumes that we know what our neighbors are.
  501. try
  502. {
  503. foreach (ulong regionHandle in presence.KnownChildRegionHandles)
  504. {
  505. if (regionHandle != m_regionInfo.RegionHandle)
  506. {
  507. SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync;
  508. d.BeginInvoke(cAgentData, regionHandle,
  509. SendChildAgentDataUpdateCompleted,
  510. d);
  511. }
  512. }
  513. }
  514. catch (InvalidOperationException)
  515. {
  516. // We're ignoring a collection was modified error because this data gets old and outdated fast.
  517. }
  518. }
  519. public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle);
  520. /// <summary>
  521. /// This Closes child agents on neighboring regions
  522. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
  523. /// </summary>
  524. protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle)
  525. {
  526. m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle);
  527. // let's do our best, but there's not much we can do if the neighbour doesn't accept.
  528. //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
  529. m_interregionCommsOut.SendCloseAgent(regionHandle, agentID);
  530. }
  531. private void SendCloseChildAgentCompleted(IAsyncResult iar)
  532. {
  533. SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState;
  534. icon.EndInvoke(iar);
  535. }
  536. public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst)
  537. {
  538. foreach (ulong handle in regionslst)
  539. {
  540. SendCloseChildAgentDelegate d = SendCloseChildAgentAsync;
  541. d.BeginInvoke(agentID, handle,
  542. SendCloseChildAgentCompleted,
  543. d);
  544. }
  545. }
  546. /// <summary>
  547. /// Helper function to request neighbors from grid-comms
  548. /// </summary>
  549. /// <param name="regionHandle"></param>
  550. /// <returns></returns>
  551. public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
  552. {
  553. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
  554. return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
  555. }
  556. /// <summary>
  557. /// Helper function to request neighbors from grid-comms
  558. /// </summary>
  559. /// <param name="regionID"></param>
  560. /// <returns></returns>
  561. public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
  562. {
  563. //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
  564. return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
  565. }
  566. /// <summary>
  567. /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
  568. /// </summary>
  569. /// <param name="minX"></param>
  570. /// <param name="minY"></param>
  571. /// <param name="maxX"></param>
  572. /// <param name="maxY"></param>
  573. public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
  574. {
  575. List<MapBlockData> mapBlocks;
  576. mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
  577. remoteClient.SendMapBlock(mapBlocks, 0);
  578. }
  579. /// <summary>
  580. /// Try to teleport an agent to a new region.
  581. /// </summary>
  582. /// <param name="remoteClient"></param>
  583. /// <param name="RegionHandle"></param>
  584. /// <param name="position"></param>
  585. /// <param name="lookAt"></param>
  586. /// <param name="flags"></param>
  587. public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
  588. Vector3 lookAt, uint teleportFlags)
  589. {
  590. if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
  591. return;
  592. bool destRegionUp = true;
  593. IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
  594. if (regionHandle == m_regionInfo.RegionHandle)
  595. {
  596. m_log.DebugFormat(
  597. "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
  598. position, m_regionInfo.RegionName);
  599. // Teleport within the same region
  600. if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0)
  601. {
  602. Vector3 emergencyPos = new Vector3(128, 128, 128);
  603. m_log.WarnFormat(
  604. "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
  605. position, avatar.Name, avatar.UUID, emergencyPos);
  606. position = emergencyPos;
  607. }
  608. // TODO: Get proper AVG Height
  609. float localAVHeight = 1.56f;
  610. float posZLimit = (float)avatar.Scene.GetLandHeight((int)position.X, (int)position.Y);
  611. float newPosZ = posZLimit + localAVHeight;
  612. if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
  613. {
  614. position.Z = newPosZ;
  615. }
  616. // Only send this if the event queue is null
  617. if (eq == null)
  618. avatar.ControllingClient.SendTeleportLocationStart();
  619. avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
  620. avatar.Teleport(position);
  621. }
  622. else
  623. {
  624. RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
  625. if (reg != null)
  626. {
  627. m_log.DebugFormat(
  628. "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
  629. position, reg.RegionName);
  630. if (eq == null)
  631. avatar.ControllingClient.SendTeleportLocationStart();
  632. // Let's do DNS resolution only once in this process, please!
  633. // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
  634. // it's actually doing a lot of work.
  635. IPEndPoint endPoint = reg.ExternalEndPoint;
  636. if (endPoint.Address == null)
  637. {
  638. // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
  639. destRegionUp = false;
  640. }
  641. if (destRegionUp)
  642. {
  643. uint newRegionX = (uint)(reg.RegionHandle >> 40);
  644. uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
  645. uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
  646. uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
  647. // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
  648. // both regions
  649. if (avatar.ParentID != (uint)0)
  650. avatar.StandUp();
  651. if (!avatar.ValidateAttachments())
  652. {
  653. avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
  654. return;
  655. }
  656. // the avatar.Close below will clear the child region list. We need this below for (possibly)
  657. // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
  658. //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
  659. // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
  660. // failure at this point (unlike a border crossing failure). So perhaps this can never fail
  661. // once we reach here...
  662. //avatar.Scene.RemoveCapsHandler(avatar.UUID);
  663. string capsPath = String.Empty;
  664. AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
  665. agentCircuit.BaseFolder = UUID.Zero;
  666. agentCircuit.InventoryFolder = UUID.Zero;
  667. agentCircuit.startpos = position;
  668. agentCircuit.child = true;
  669. if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
  670. {
  671. // brand new agent, let's create a new caps seed
  672. agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
  673. }
  674. // Let's create an agent there if one doesn't exist yet.
  675. //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
  676. if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit))
  677. {
  678. avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports.");
  679. return;
  680. }
  681. // OK, it got this agent. Let's close some child agents
  682. avatar.CloseChildAgents(newRegionX, newRegionY);
  683. if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
  684. {
  685. capsPath
  686. = "http://"
  687. + reg.ExternalHostName
  688. + ":"
  689. + reg.HttpPort
  690. + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
  691. if (eq != null)
  692. {
  693. OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, endPoint);
  694. eq.Enqueue(Item, avatar.UUID);
  695. // ES makes the client send a UseCircuitCode message to the destination,
  696. // which triggers a bunch of things there.
  697. // So let's wait
  698. Thread.Sleep(2000);
  699. Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, endPoint.ToString(), capsPath);
  700. eq.Enqueue(Item, avatar.UUID);
  701. }
  702. else
  703. {
  704. avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
  705. }
  706. }
  707. else
  708. {
  709. agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
  710. capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
  711. + "/CAPS/" + agentCircuit.CapsPath + "0000/";
  712. }
  713. // Expect avatar crossing is a heavy-duty function at the destination.
  714. // That is where MakeRoot is called, which fetches appearance and inventory.
  715. // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
  716. //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
  717. // position, false);
  718. //{
  719. // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
  720. // // We should close that agent we just created over at destination...
  721. // List<ulong> lst = new List<ulong>();
  722. // lst.Add(reg.RegionHandle);
  723. // SendCloseChildAgentAsync(avatar.UUID, lst);
  724. // return;
  725. //}
  726. SetInTransit(avatar.UUID);
  727. // Let's send a full update of the agent. This is a synchronous call.
  728. AgentData agent = new AgentData();
  729. avatar.CopyTo(agent);
  730. agent.Position = position;
  731. agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
  732. "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
  733. m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
  734. m_log.DebugFormat(
  735. "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
  736. if (eq != null)
  737. {
  738. OSD Item = EventQueueHelper.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
  739. 4, teleportFlags, capsPath, avatar.UUID);
  740. eq.Enqueue(Item, avatar.UUID);
  741. }
  742. else
  743. {
  744. avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
  745. teleportFlags, capsPath);
  746. }
  747. // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
  748. // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
  749. // that the client contacted the destination before we send the attachments and close things here.
  750. if (!WaitForCallback(avatar.UUID))
  751. {
  752. // Client never contacted destination. Let's restore everything back
  753. avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
  754. ResetFromTransit(avatar.UUID);
  755. // Yikes! We should just have a ref to scene here.
  756. avatar.Scene.InformClientOfNeighbours(avatar);
  757. // Finally, kill the agent we just created at the destination.
  758. m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
  759. return;
  760. }
  761. // Can't go back from here
  762. if (KiPrimitive != null)
  763. {
  764. KiPrimitive(avatar.LocalId);
  765. }
  766. avatar.MakeChildAgent();
  767. // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
  768. avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
  769. // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
  770. if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
  771. {
  772. Thread.Sleep(5000);
  773. avatar.Close();
  774. CloseConnection(avatar.UUID);
  775. }
  776. // if (teleport success) // seems to be always success here
  777. // the user may change their profile information in other region,
  778. // so the userinfo in UserProfileCache is not reliable any more, delete it
  779. if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
  780. {
  781. m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
  782. m_log.DebugFormat(
  783. "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
  784. avatar.UUID);
  785. }
  786. }
  787. else
  788. {
  789. avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
  790. }
  791. }
  792. else
  793. {
  794. // TP to a place that doesn't exist (anymore)
  795. // Inform the viewer about that
  796. avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
  797. // and set the map-tile to '(Offline)'
  798. uint regX, regY;
  799. Utils.LongToUInts(regionHandle, out regX, out regY);
  800. MapBlockData block = new MapBlockData();
  801. block.X = (ushort)(regX / Constants.RegionSize);
  802. block.Y = (ushort)(regY / Constants.RegionSize);
  803. block.Access = 254; // == not there
  804. List<MapBlockData> blocks = new List<MapBlockData>();
  805. blocks.Add(block);
  806. avatar.ControllingClient.SendMapBlock(blocks, 0);
  807. }
  808. }
  809. }
  810. protected bool WaitForCallback(UUID id)
  811. {
  812. int count = 20;
  813. while (m_agentsInTransit.Contains(id) && count-- > 0)
  814. {
  815. //Console.WriteLine(" >>> Waiting... " + count);
  816. Thread.Sleep(1000);
  817. }
  818. if (count > 0)
  819. return true;
  820. else
  821. return false;
  822. }
  823. public bool ReleaseAgent(UUID id)
  824. {
  825. //Console.WriteLine(" >>> ReleaseAgent called <<< ");
  826. return ResetFromTransit(id);
  827. }
  828. protected void SetInTransit(UUID id)
  829. {
  830. lock (m_agentsInTransit)
  831. {
  832. if (!m_agentsInTransit.Contains(id))
  833. m_agentsInTransit.Add(id);
  834. }
  835. }
  836. protected bool ResetFromTransit(UUID id)
  837. {
  838. lock (m_agentsInTransit)
  839. {
  840. if (m_agentsInTransit.Contains(id))
  841. {
  842. m_agentsInTransit.Remove(id);
  843. return true;
  844. }
  845. }
  846. return false;
  847. }
  848. private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours)
  849. {
  850. List<ulong> handles = new List<ulong>();
  851. foreach (SimpleRegionInfo reg in neighbours)
  852. {
  853. handles.Add(reg.RegionHandle);
  854. }
  855. return handles;
  856. }
  857. private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
  858. {
  859. return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
  860. }
  861. // private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
  862. // {
  863. // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
  864. // }
  865. private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
  866. {
  867. return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
  868. }
  869. /// <summary>
  870. /// Inform a neighbouring region that an avatar is about to cross into it.
  871. /// </summary>
  872. /// <param name="regionhandle"></param>
  873. /// <param name="agentID"></param>
  874. /// <param name="position"></param>
  875. public bool CrossToNeighbouringRegion(ulong regionhandle, UUID agentID, Vector3 position, bool isFlying)
  876. {
  877. return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying);
  878. }
  879. public bool PrimCrossToNeighboringRegion(ulong regionhandle, UUID primID, string objData, int XMLMethod)
  880. {
  881. return m_commsProvider.InterRegion.InformRegionOfPrimCrossing(regionhandle, primID, objData, XMLMethod);
  882. }
  883. public Dictionary<string, string> GetGridSettings()
  884. {
  885. return m_commsProvider.GridService.GetGridSettings();
  886. }
  887. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
  888. {
  889. m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
  890. }
  891. // deprecated as of 2008-08-27
  892. public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
  893. {
  894. m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
  895. }
  896. public void ClearUserAgent(UUID avatarID)
  897. {
  898. m_commsProvider.UserService.ClearUserAgent(avatarID);
  899. }
  900. public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
  901. {
  902. m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
  903. }
  904. public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
  905. {
  906. m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
  907. }
  908. public void RemoveUserFriend(UUID friendlistowner, UUID friend)
  909. {
  910. m_commsProvider.RemoveUserFriend(friendlistowner, friend);
  911. }
  912. public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
  913. {
  914. return m_commsProvider.GetUserFriendList(friendlistowner);
  915. }
  916. public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
  917. {
  918. return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
  919. }
  920. public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
  921. {
  922. return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
  923. }
  924. public List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
  925. {
  926. return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
  927. }
  928. // private void Dump(string msg, List<ulong> handles)
  929. // {
  930. // Console.WriteLine("-------------- HANDLE DUMP ({0}) ---------", msg);
  931. // foreach (ulong handle in handles)
  932. // {
  933. // uint x, y;
  934. // Utils.LongToUInts(handle, out x, out y);
  935. // x = x / Constants.RegionSize;
  936. // y = y / Constants.RegionSize;
  937. // Console.WriteLine("({0}, {1})", x, y);
  938. // }
  939. // }
  940. }
  941. }