HGGridServicesGridMode.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /**
  2. * Copyright (c) 2008, Contributors. All rights reserved.
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * * Neither the name of the Organizations nor the names of Individual
  14. * Contributors may be used to endorse or promote products derived from
  15. * this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  20. * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  22. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  23. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  25. * OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. */
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Reflection;
  31. using log4net;
  32. using OpenMetaverse;
  33. using OpenSim.Framework;
  34. using OpenSim.Framework.Communications.Cache;
  35. using OpenSim.Framework.Servers;
  36. using OpenSim.Region.Communications.OGS1;
  37. using OpenSim.Region.Framework.Scenes;
  38. namespace OpenSim.Region.Communications.Hypergrid
  39. {
  40. public class HGGridServicesGridMode : HGGridServices
  41. {
  42. //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  43. /// <summary>
  44. /// Encapsulate remote backend services for manipulation of grid regions
  45. /// </summary>
  46. private OGS1GridServices m_remoteBackend = null;
  47. public OGS1GridServices RemoteBackend
  48. {
  49. get { return m_remoteBackend; }
  50. }
  51. public override string gdebugRegionName
  52. {
  53. get { return m_remoteBackend.gdebugRegionName; }
  54. set { m_remoteBackend.gdebugRegionName = value; }
  55. }
  56. public override bool RegionLoginsEnabled
  57. {
  58. get { return m_remoteBackend.RegionLoginsEnabled; }
  59. set { m_remoteBackend.RegionLoginsEnabled = value; }
  60. }
  61. public HGGridServicesGridMode(NetworkServersInfo servers_info, BaseHttpServer httpServe,
  62. IAssetCache asscache, SceneManager sman, UserProfileCacheService userv)
  63. : base(servers_info, httpServe, asscache, sman)
  64. {
  65. m_remoteBackend = new OGS1GridServices(servers_info, httpServe);
  66. m_userProfileCache = userv;
  67. }
  68. #region IGridServices interface
  69. public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
  70. {
  71. if (!regionInfo.RegionID.Equals(UUID.Zero))
  72. {
  73. m_regionsOnInstance.Add(regionInfo);
  74. return m_remoteBackend.RegisterRegion(regionInfo);
  75. }
  76. else
  77. return base.RegisterRegion(regionInfo);
  78. }
  79. public override bool DeregisterRegion(RegionInfo regionInfo)
  80. {
  81. bool success = base.DeregisterRegion(regionInfo);
  82. if (!success)
  83. success = m_remoteBackend.DeregisterRegion(regionInfo);
  84. return success;
  85. }
  86. public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
  87. {
  88. List<SimpleRegionInfo> neighbours = m_remoteBackend.RequestNeighbours(x, y);
  89. //List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
  90. //neighbours.AddRange(remotes);
  91. return neighbours;
  92. }
  93. public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
  94. {
  95. RegionInfo info = m_remoteBackend.RequestNeighbourInfo(Region_UUID);
  96. if (info == null)
  97. info = base.RequestNeighbourInfo(Region_UUID);
  98. return info;
  99. }
  100. public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
  101. {
  102. RegionInfo info = base.RequestNeighbourInfo(regionHandle);
  103. if (info == null)
  104. info = m_remoteBackend.RequestNeighbourInfo(regionHandle);
  105. return info;
  106. }
  107. public override RegionInfo RequestClosestRegion(string regionName)
  108. {
  109. RegionInfo info = m_remoteBackend.RequestClosestRegion(regionName);
  110. if (info == null)
  111. info = base.RequestClosestRegion(regionName);
  112. return info;
  113. }
  114. public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
  115. {
  116. List<MapBlockData> neighbours = m_remoteBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
  117. List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
  118. neighbours.AddRange(remotes);
  119. return neighbours;
  120. }
  121. public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
  122. {
  123. LandData land = m_remoteBackend.RequestLandData(regionHandle, x, y);
  124. if (land == null)
  125. land = base.RequestLandData(regionHandle, x, y);
  126. return land;
  127. }
  128. public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
  129. {
  130. List<RegionInfo> infos = m_remoteBackend.RequestNamedRegions(name, maxNumber);
  131. List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
  132. infos.AddRange(remotes);
  133. return infos;
  134. }
  135. #endregion
  136. }
  137. }