HGGridServicesGridMode.cs 6.0 KB

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