aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs285
1 files changed, 285 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
new file mode 100644
index 0000000..23258df
--- /dev/null
+++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
@@ -0,0 +1,285 @@
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
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Servers;
37using OpenSim.Region.Communications.OGS1;
38using OpenSim.Region.Environment.Scenes;
39
40using OpenMetaverse;
41
42using log4net;
43
44namespace OpenSim.Region.Communications.Hypergrid
45{
46 public class HGGridServicesGridMode : HGGridServices
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 /// <summary>
51 /// Encapsulate remote backend services for manipulation of grid regions
52 /// </summary>
53 private OGS1GridServices m_remoteBackend = null;
54
55 public OGS1GridServices RemoteBackend
56 {
57 get { return m_remoteBackend; }
58 }
59
60
61 public override string gdebugRegionName
62 {
63 get { return m_remoteBackend.gdebugRegionName; }
64 set { m_remoteBackend.gdebugRegionName = value; }
65 }
66
67 public override bool RegionLoginsEnabled
68 {
69 get { return m_remoteBackend.RegionLoginsEnabled; }
70 set { m_remoteBackend.RegionLoginsEnabled = value; }
71 }
72
73 public HGGridServicesGridMode(NetworkServersInfo servers_info, BaseHttpServer httpServe,
74 AssetCache asscache, SceneManager sman, UserProfileCacheService userv)
75 : base(servers_info, httpServe, asscache, sman)
76 {
77 m_remoteBackend = new OGS1GridServices(servers_info, httpServe);
78 // Let's deregister this, so we can handle it here first
79 InterRegionSingleton.Instance.OnChildAgent -= m_remoteBackend.IncomingChildAgent;
80 InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent;
81 m_userProfileCache = userv;
82 }
83
84 #region IGridServices interface
85
86 public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
87 {
88 if (!regionInfo.RegionID.Equals(UUID.Zero))
89 {
90 m_regionsOnInstance.Add(regionInfo);
91 return m_remoteBackend.RegisterRegion(regionInfo);
92 }
93 else
94 return base.RegisterRegion(regionInfo);
95 }
96
97 public override bool DeregisterRegion(RegionInfo regionInfo)
98 {
99 bool success = m_remoteBackend.DeregisterRegion(regionInfo);
100 if (!success)
101 success = base.DeregisterRegion(regionInfo);
102 return success;
103 }
104
105 public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
106 {
107 List<SimpleRegionInfo> neighbours = m_remoteBackend.RequestNeighbours(x, y);
108 List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
109 neighbours.AddRange(remotes);
110
111 return neighbours;
112 }
113
114 public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
115 {
116 RegionInfo info = m_remoteBackend.RequestNeighbourInfo(Region_UUID);
117 if (info == null)
118 info = base.RequestNeighbourInfo(Region_UUID);
119 return info;
120 }
121
122 public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
123 {
124 RegionInfo info = m_remoteBackend.RequestNeighbourInfo(regionHandle);
125 if (info == null)
126 info = base.RequestNeighbourInfo(regionHandle);
127 return info;
128 }
129
130 public override RegionInfo RequestClosestRegion(string regionName)
131 {
132 RegionInfo info = m_remoteBackend.RequestClosestRegion(regionName);
133 if (info == null)
134 info = base.RequestClosestRegion(regionName);
135 return info;
136 }
137
138 public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
139 {
140 List<MapBlockData> neighbours = m_remoteBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
141 List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
142 neighbours.AddRange(remotes);
143
144 return neighbours;
145 }
146
147 public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
148 {
149 LandData land = m_remoteBackend.RequestLandData(regionHandle, x, y);
150 if (land == null)
151 land = base.RequestLandData(regionHandle, x, y);
152 return land;
153 }
154
155 public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
156 {
157 List<RegionInfo> infos = m_remoteBackend.RequestNamedRegions(name, maxNumber);
158 List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
159 infos.AddRange(remotes);
160 return infos;
161 }
162
163 #endregion
164
165 #region IInterRegionCommunications interface
166
167 public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId)
168 {
169 return m_remoteBackend.AcknowledgeAgentCrossed(regionHandle, agentId);
170 }
171
172 public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID)
173 {
174 return m_remoteBackend.AcknowledgePrimCrossed(regionHandle, primID);
175 }
176
177 public override bool CheckRegion(string address, uint port)
178 {
179 return m_remoteBackend.CheckRegion(address, port);
180 }
181
182 public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
183 {
184 return m_remoteBackend.ChildAgentUpdate(regionHandle, cAgentData);
185 }
186
187 public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying)
188 {
189 if (base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying))
190 return true;
191 return m_remoteBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
192 }
193
194 public override bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying)
195 {
196 return m_remoteBackend.ExpectPrimCrossing(regionHandle, primID, position, isFlying);
197 }
198
199 public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
200 {
201 CachedUserInfo user = m_userProfileCache.GetUserDetails(agentData.AgentID);
202
203 if (IsLocalUser(user))
204 {
205 Console.WriteLine("XXX Home User XXX");
206 if (IsHyperlinkRegion(regionHandle))
207 {
208 Console.WriteLine("XXX Going Hyperlink XXX");
209 return base.InformRegionOfChildAgent(regionHandle, agentData);
210 }
211 else
212 {
213 // non-hypergrid case
214 Console.WriteLine("XXX Going local-grid region XXX");
215 return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData);
216 }
217 }
218
219 // Foregin users
220 Console.WriteLine("XXX Foreign User XXX");
221 if (IsLocalRegion(regionHandle)) // regions on the same instance
222 {
223 Console.WriteLine("XXX Going onInstance region XXX");
224 return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData);
225 }
226
227 if (IsHyperlinkRegion(regionHandle)) // hyperlinked regions
228 {
229 Console.WriteLine("XXX Going Hyperlink XXX");
230 return base.InformRegionOfChildAgent(regionHandle, agentData);
231 }
232 else
233 {
234 // foreign user going to a non-local region on the same grid
235 // We need to inform that region about this user before
236 // proceeding to the normal backend process.
237 Console.WriteLine("XXX Going local-grid region XXX");
238 RegionInfo regInfo = RequestNeighbourInfo(regionHandle);
239 if (regInfo != null)
240 InformRegionOfUser(regInfo, agentData);
241 return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData);
242 }
243
244 }
245
246 public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod)
247 {
248 return m_remoteBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod);
249 }
250
251 public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle)
252 {
253 if (m_remoteBackend.RegionUp(region, regionhandle))
254 return true;
255 return base.RegionUp(region, regionhandle);
256 }
257
258 public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID)
259 {
260 return m_remoteBackend.TellRegionToCloseChildConnection(regionHandle, agentID);
261 }
262
263
264 #endregion
265
266 #region Methods triggered by calls from external instances
267
268 /// <summary>
269 ///
270 /// </summary>
271 /// <param name="regionHandle"></param>
272 /// <param name="agentData"></param>
273 /// <returns></returns>
274 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
275 {
276 HGIncomingChildAgent(regionHandle, agentData);
277
278 m_log.Info("[HGrid]: Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname);
279
280 return m_remoteBackend.IncomingChildAgent(regionHandle, agentData);
281 }
282 #endregion
283
284 }
285}