aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2009-09-23 17:20:07 -0700
committerDiva Canto2009-09-23 17:20:07 -0700
commit67276589c883fe1a74d8d52057db1431d637dade (patch)
treedea80b87d7e11fb9a15c4b6e22c2c051e08eaf25 /OpenSim
parentMerge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-67276589c883fe1a74d8d52057db1431d637dade.zip
opensim-SC_OLD-67276589c883fe1a74d8d52057db1431d637dade.tar.gz
opensim-SC_OLD-67276589c883fe1a74d8d52057db1431d637dade.tar.bz2
opensim-SC_OLD-67276589c883fe1a74d8d52057db1431d637dade.tar.xz
Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo.
Added grid configs to standalones.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs36
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs82
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs18
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs15
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs7
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs39
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs5
-rw-r--r--OpenSim/Services/GridService/GridService.cs32
-rw-r--r--OpenSim/Services/GridService/GridServiceBase.cs2
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs249
11 files changed, 368 insertions, 118 deletions
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index 588b8ac..03489f9 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -40,6 +40,7 @@ namespace OpenSim.Data.Null
40 40
41 public NullRegionData(string connectionString, string realm) 41 public NullRegionData(string connectionString, string realm)
42 { 42 {
43 Console.WriteLine("[XXX] NullRegionData constructor");
43 } 44 }
44 45
45 public List<RegionData> Get(string regionName, UUID scopeID) 46 public List<RegionData> Get(string regionName, UUID scopeID)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
index 2a862d4..36915ef 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
@@ -37,6 +37,7 @@ using OpenSim.Framework.Console;
37using OpenSim.Region.Framework; 37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid; 39using OpenSim.Region.Framework.Scenes.Hypergrid;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 41
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
42{ 43{
@@ -121,12 +122,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
121 if (cmdparams[2].Contains(":")) 122 if (cmdparams[2].Contains(":"))
122 { 123 {
123 // New format 124 // New format
124 uint xloc, yloc; 125 int xloc, yloc;
125 string mapName; 126 string mapName;
126 try 127 try
127 { 128 {
128 xloc = Convert.ToUInt32(cmdparams[0]); 129 xloc = Convert.ToInt32(cmdparams[0]);
129 yloc = Convert.ToUInt32(cmdparams[1]); 130 yloc = Convert.ToInt32(cmdparams[1]);
130 mapName = cmdparams[2]; 131 mapName = cmdparams[2];
131 if (cmdparams.Length > 3) 132 if (cmdparams.Length > 3)
132 for (int i = 3; i < cmdparams.Length; i++) 133 for (int i = 3; i < cmdparams.Length; i++)
@@ -143,19 +144,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
143 return; 144 return;
144 } 145 }
145 146
147 // Convert cell coordinates given by the user to meters
148 xloc = xloc * (int)Constants.RegionSize;
149 yloc = yloc * (int)Constants.RegionSize;
146 m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); 150 m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc);
147 } 151 }
148 else 152 else
149 { 153 {
150 // old format 154 // old format
151 SimpleRegionInfo regInfo; 155 GridRegion regInfo;
152 uint xloc, yloc; 156 int xloc, yloc;
153 uint externalPort; 157 uint externalPort;
154 string externalHostName; 158 string externalHostName;
155 try 159 try
156 { 160 {
157 xloc = Convert.ToUInt32(cmdparams[0]); 161 xloc = Convert.ToInt32(cmdparams[0]);
158 yloc = Convert.ToUInt32(cmdparams[1]); 162 yloc = Convert.ToInt32(cmdparams[1]);
159 externalPort = Convert.ToUInt32(cmdparams[3]); 163 externalPort = Convert.ToUInt32(cmdparams[3]);
160 externalHostName = cmdparams[2]; 164 externalHostName = cmdparams[2];
161 //internalPort = Convert.ToUInt32(cmdparams[4]); 165 //internalPort = Convert.ToUInt32(cmdparams[4]);
@@ -168,7 +172,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
168 return; 172 return;
169 } 173 }
170 174
171 //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) 175 // Convert cell coordinates given by the user to meters
176 xloc = xloc * (int)Constants.RegionSize;
177 yloc = yloc * (int)Constants.RegionSize;
172 if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) 178 if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
173 { 179 {
174 if (cmdparams.Length >= 5) 180 if (cmdparams.Length >= 5)
@@ -245,14 +251,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
245 251
246 private void ReadLinkFromConfig(IConfig config) 252 private void ReadLinkFromConfig(IConfig config)
247 { 253 {
248 SimpleRegionInfo regInfo; 254 GridRegion regInfo;
249 uint xloc, yloc; 255 int xloc, yloc;
250 uint externalPort; 256 uint externalPort;
251 string externalHostName; 257 string externalHostName;
252 uint realXLoc, realYLoc; 258 uint realXLoc, realYLoc;
253 259
254 xloc = Convert.ToUInt32(config.GetString("xloc", "0")); 260 xloc = Convert.ToInt32(config.GetString("xloc", "0"));
255 yloc = Convert.ToUInt32(config.GetString("yloc", "0")); 261 yloc = Convert.ToInt32(config.GetString("yloc", "0"));
256 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); 262 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
257 externalHostName = config.GetString("externalHostName", ""); 263 externalHostName = config.GetString("externalHostName", "");
258 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); 264 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
@@ -260,14 +266,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
260 266
261 if (m_enableAutoMapping) 267 if (m_enableAutoMapping)
262 { 268 {
263 xloc = (uint)((xloc % 100) + m_autoMappingX); 269 xloc = (int)((xloc % 100) + m_autoMappingX);
264 yloc = (uint)((yloc % 100) + m_autoMappingY); 270 yloc = (int)((yloc % 100) + m_autoMappingY);
265 } 271 }
266 272
267 if (((realXLoc == 0) && (realYLoc == 0)) || 273 if (((realXLoc == 0) && (realYLoc == 0)) ||
268 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && 274 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
269 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) 275 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
270 { 276 {
277 xloc = xloc * (int)Constants.RegionSize;
278 yloc = yloc * (int)Constants.RegionSize;
271 if ( 279 if (
272 m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, 280 m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort,
273 externalHostName, out regInfo)) 281 externalHostName, out regInfo))
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index c6ade15..0c2a835 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -36,6 +36,7 @@ using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.Framework.Scenes.Hypergrid; 37using OpenSim.Region.Framework.Scenes.Hypergrid;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base; 40using OpenSim.Server.Base;
40using OpenSim.Services.Connectors.Grid; 41using OpenSim.Services.Connectors.Grid;
41using OpenSim.Framework.Console; 42using OpenSim.Framework.Console;
@@ -59,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
59 private HypergridServiceConnector m_HypergridServiceConnector; 60 private HypergridServiceConnector m_HypergridServiceConnector;
60 61
61 // Hyperlink regions are hyperlinks on the map 62 // Hyperlink regions are hyperlinks on the map
62 protected Dictionary<UUID, SimpleRegionInfo> m_HyperlinkRegions = new Dictionary<UUID, SimpleRegionInfo>(); 63 protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
63 64
64 // Known regions are home regions of visiting foreign users. 65 // Known regions are home regions of visiting foreign users.
65 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when 66 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
66 // the visitor goes away. They are mapped to X=0 on the map. 67 // the visitor goes away. They are mapped to X=0 on the map.
67 // This is key-ed on agent ID 68 // This is key-ed on agent ID
68 protected Dictionary<UUID, SimpleRegionInfo> m_knownRegions = new Dictionary<UUID, SimpleRegionInfo>(); 69 protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>();
69 70
70 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); 71 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
71 72
@@ -184,7 +185,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
184 185
185 #region IGridService 186 #region IGridService
186 187
187 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 188 public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
188 { 189 {
189 // Region doesn't exist here. Trying to link remote region 190 // Region doesn't exist here. Trying to link remote region
190 if (regionInfo.RegionID.Equals(UUID.Zero)) 191 if (regionInfo.RegionID.Equals(UUID.Zero))
@@ -222,7 +223,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
222 } 223 }
223 // Try the foreign users home collection 224 // Try the foreign users home collection
224 225
225 foreach (SimpleRegionInfo r in m_knownRegions.Values) 226 foreach (GridRegion r in m_knownRegions.Values)
226 if (r.RegionID == regionID) 227 if (r.RegionID == regionID)
227 { 228 {
228 RemoveHyperlinkHomeRegion(regionID); 229 RemoveHyperlinkHomeRegion(regionID);
@@ -233,21 +234,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
233 return m_GridServiceConnector.DeregisterRegion(regionID); 234 return m_GridServiceConnector.DeregisterRegion(regionID);
234 } 235 }
235 236
236 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 237 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
237 { 238 {
238 // No serving neighbours on hyperliked regions. 239 // No serving neighbours on hyperliked regions.
239 // Just the regular regions. 240 // Just the regular regions.
240 return m_GridServiceConnector.GetNeighbours(scopeID, regionID); 241 return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
241 } 242 }
242 243
243 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 244 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
244 { 245 {
245 // Try the hyperlink collection 246 // Try the hyperlink collection
246 if (m_HyperlinkRegions.ContainsKey(regionID)) 247 if (m_HyperlinkRegions.ContainsKey(regionID))
247 return m_HyperlinkRegions[regionID]; 248 return m_HyperlinkRegions[regionID];
248 249
249 // Try the foreign users home collection 250 // Try the foreign users home collection
250 foreach (SimpleRegionInfo r in m_knownRegions.Values) 251 foreach (GridRegion r in m_knownRegions.Values)
251 if (r.RegionID == regionID) 252 if (r.RegionID == regionID)
252 return m_knownRegions[regionID]; 253 return m_knownRegions[regionID];
253 254
@@ -255,19 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
255 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); 256 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
256 } 257 }
257 258
258 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 259 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
259 { 260 {
260 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; 261 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
261 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; 262 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
262 // Try the hyperlink collection 263 // Try the hyperlink collection
263 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 264 foreach (GridRegion r in m_HyperlinkRegions.Values)
264 { 265 {
265 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) 266 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
266 return r; 267 return r;
267 } 268 }
268 269
269 // Try the foreign users home collection 270 // Try the foreign users home collection
270 foreach (SimpleRegionInfo r in m_knownRegions.Values) 271 foreach (GridRegion r in m_knownRegions.Values)
271 { 272 {
272 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) 273 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
273 return r; 274 return r;
@@ -277,22 +278,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
277 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); 278 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
278 } 279 }
279 280
280 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 281 public GridRegion GetRegionByName(UUID scopeID, string regionName)
281 { 282 {
282 // Try normal grid first 283 // Try normal grid first
283 SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); 284 GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
284 if (region != null) 285 if (region != null)
285 return region; 286 return region;
286 287
287 // Try the hyperlink collection 288 // Try the hyperlink collection
288 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 289 foreach (GridRegion r in m_HyperlinkRegions.Values)
289 { 290 {
290 if (r.RegionName == regionName) 291 if (r.RegionName == regionName)
291 return r; 292 return r;
292 } 293 }
293 294
294 // Try the foreign users home collection 295 // Try the foreign users home collection
295 foreach (SimpleRegionInfo r in m_knownRegions.Values) 296 foreach (GridRegion r in m_knownRegions.Values)
296 { 297 {
297 if (r.RegionName == regionName) 298 if (r.RegionName == regionName)
298 return r; 299 return r;
@@ -300,9 +301,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
300 return null; 301 return null;
301 } 302 }
302 303
303 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 304 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
304 { 305 {
305 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 306 List<GridRegion> rinfos = new List<GridRegion>();
306 307
307 // Commenting until regionname exists 308 // Commenting until regionname exists
308 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 309 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
@@ -313,15 +314,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
313 return rinfos; 314 return rinfos;
314 } 315 }
315 316
316 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 317 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
317 { 318 {
318 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; 319 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
319 int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; 320 int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
320 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; 321 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
321 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; 322 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
322 323
323 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 324 List<GridRegion> rinfos = new List<GridRegion>();
324 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 325 foreach (GridRegion r in m_HyperlinkRegions.Values)
325 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && 326 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
326 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) 327 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
327 rinfos.Add(r); 328 rinfos.Add(r);
@@ -335,7 +336,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
335 336
336 #region Auxiliary 337 #region Auxiliary
337 338
338 private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) 339 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
339 { 340 {
340 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); 341 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
341 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 342 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
@@ -347,7 +348,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
347 m_HyperlinkHandles.Remove(regionID); 348 m_HyperlinkHandles.Remove(regionID);
348 } 349 }
349 350
350 private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle) 351 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
351 { 352 {
352 m_knownRegions.Add(userID, regionInfo); 353 m_knownRegions.Add(userID, regionInfo);
353 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 354 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
@@ -355,7 +356,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
355 356
356 private void RemoveHyperlinkHomeRegion(UUID regionID) 357 private void RemoveHyperlinkHomeRegion(UUID regionID)
357 { 358 {
358 foreach (KeyValuePair<UUID, SimpleRegionInfo> kvp in m_knownRegions) 359 foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions)
359 { 360 {
360 if (kvp.Value.RegionID == regionID) 361 if (kvp.Value.RegionID == regionID)
361 { 362 {
@@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
370 371
371 private static Random random = new Random(); 372 private static Random random = new Random();
372 373
373 public SimpleRegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) 374 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
374 { 375 {
375 string host = "127.0.0.1"; 376 string host = "127.0.0.1";
376 string portstr; 377 string portstr;
@@ -404,7 +405,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
404 if ((ipaddr != null) && 405 if ((ipaddr != null) &&
405 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) 406 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
406 { 407 {
407 SimpleRegionInfo regInfo; 408 GridRegion regInfo;
408 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); 409 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
409 if (success) 410 if (success)
410 { 411 {
@@ -417,18 +418,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
417 } 418 }
418 419
419 // From the map search and secondlife://blah 420 // From the map search and secondlife://blah
420 public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 421 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
421 { 422 {
422 uint xloc = (uint)(random.Next(0, Int16.MaxValue)); 423 int xloc = random.Next(0, Int16.MaxValue);
423 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 424 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
424 } 425 }
425 426
426 public bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, 427 public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
427 string externalRegionName, uint externalPort, string externalHostName, out SimpleRegionInfo regInfo) 428 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
428 { 429 {
429 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); 430 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
430 431
431 regInfo = new SimpleRegionInfo(); 432 regInfo = new GridRegion();
432 regInfo.RegionName = externalRegionName; 433 regInfo.RegionName = externalRegionName;
433 regInfo.HttpPort = externalPort; 434 regInfo.HttpPort = externalPort;
434 regInfo.ExternalHostName = externalHostName; 435 regInfo.ExternalHostName = externalHostName;
@@ -456,7 +457,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
456 return false; 457 return false;
457 } 458 }
458 459
459 uint x, y; 460 int x, y;
460 if (!Check4096(m_scene, regInfo, out x, out y)) 461 if (!Check4096(m_scene, regInfo, out x, out y))
461 { 462 {
462 DeregisterRegion(regInfo.RegionID); 463 DeregisterRegion(regInfo.RegionID);
@@ -481,7 +482,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
481 482
482 public bool TryUnlinkRegion(Scene m_scene, string mapName) 483 public bool TryUnlinkRegion(Scene m_scene, string mapName)
483 { 484 {
484 SimpleRegionInfo regInfo = null; 485 GridRegion regInfo = null;
485 if (mapName.Contains(":")) 486 if (mapName.Contains(":"))
486 { 487 {
487 string host = "127.0.0.1"; 488 string host = "127.0.0.1";
@@ -504,13 +505,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
504 // { 505 // {
505 // regionName = parts[2]; 506 // regionName = parts[2];
506 // } 507 // }
507 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 508 foreach (GridRegion r in m_HyperlinkRegions.Values)
508 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) 509 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
509 regInfo = r; 510 regInfo = r;
510 } 511 }
511 else 512 else
512 { 513 {
513 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) 514 foreach (GridRegion r in m_HyperlinkRegions.Values)
514 if (r.RegionName.Equals(mapName)) 515 if (r.RegionName.Equals(mapName))
515 regInfo = r; 516 regInfo = r;
516 } 517 }
@@ -530,22 +531,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
530 /// </summary> 531 /// </summary>
531 /// <param name="regInfo"></param> 532 /// <param name="regInfo"></param>
532 /// <returns></returns> 533 /// <returns></returns>
533 public bool Check4096(Scene m_scene, SimpleRegionInfo regInfo, out uint x, out uint y) 534 public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y)
534 { 535 {
535 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; 536 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
536 Utils.LongToUInts(realHandle, out x, out y); 537 uint ux = 0, uy = 0;
537 x = x / Constants.RegionSize; 538 Utils.LongToUInts(realHandle, out ux, out uy);
538 y = y / Constants.RegionSize; 539 x = (int)(ux / Constants.RegionSize);
540 y = (int)(uy / Constants.RegionSize);
539 541
540 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || 542 if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) ||
541 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) 543 (Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096))
542 { 544 {
543 return false; 545 return false;
544 } 546 }
545 return true; 547 return true;
546 } 548 }
547 549
548 public bool CheckCoords(uint thisx, uint thisy, uint x, uint y) 550 public bool CheckCoords(uint thisx, uint thisy, int x, int y)
549 { 551 {
550 if ((thisx == x) && (thisy == y)) 552 if ((thisx == x) && (thisy == y))
551 return false; 553 return false;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index c1b7235..743d3b9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -35,6 +35,7 @@ using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
@@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
56 57
57 public LocalGridServicesConnector(IConfigSource source) 58 public LocalGridServicesConnector(IConfigSource source)
58 { 59 {
60 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
59 InitialiseService(source); 61 InitialiseService(source);
60 } 62 }
61 63
@@ -111,7 +113,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
111 113
112 if (m_GridService == null) 114 if (m_GridService == null)
113 { 115 {
114 m_log.Error("[LOCAL GRID CONNECTOR]: Can't load asset service"); 116 m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service");
115 return; 117 return;
116 } 118 }
117 } 119 }
@@ -144,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
144 146
145 #region IGridService 147 #region IGridService
146 148
147 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 149 public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
148 { 150 {
149 return m_GridService.RegisterRegion(scopeID, regionInfo); 151 return m_GridService.RegisterRegion(scopeID, regionInfo);
150 } 152 }
@@ -154,32 +156,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
154 return m_GridService.DeregisterRegion(regionID); 156 return m_GridService.DeregisterRegion(regionID);
155 } 157 }
156 158
157 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 159 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
158 { 160 {
159 return m_GridService.GetNeighbours(scopeID, regionID); 161 return m_GridService.GetNeighbours(scopeID, regionID);
160 } 162 }
161 163
162 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 164 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
163 { 165 {
164 return m_GridService.GetRegionByUUID(scopeID, regionID); 166 return m_GridService.GetRegionByUUID(scopeID, regionID);
165 } 167 }
166 168
167 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 169 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
168 { 170 {
169 return m_GridService.GetRegionByPosition(scopeID, x, y); 171 return m_GridService.GetRegionByPosition(scopeID, x, y);
170 } 172 }
171 173
172 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 174 public GridRegion GetRegionByName(UUID scopeID, string regionName)
173 { 175 {
174 return m_GridService.GetRegionByName(scopeID, regionName); 176 return m_GridService.GetRegionByName(scopeID, regionName);
175 } 177 }
176 178
177 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 179 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
178 { 180 {
179 return m_GridService.GetRegionsByName(scopeID, name, maxNumber); 181 return m_GridService.GetRegionsByName(scopeID, name, maxNumber);
180 } 182 }
181 183
182 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 184 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
183 { 185 {
184 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); 186 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
185 } 187 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 4303fa8..91a808b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -37,6 +37,7 @@ using OpenSim.Services.Connectors;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 41
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
42{ 43{
@@ -129,7 +130,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
129 130
130 #region IGridService 131 #region IGridService
131 132
132 public override bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 133 public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
133 { 134 {
134 if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) 135 if (m_LocalGridService.RegisterRegion(scopeID, regionInfo))
135 return base.RegisterRegion(scopeID, regionInfo); 136 return base.RegisterRegion(scopeID, regionInfo);
@@ -147,27 +148,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
147 148
148 // Let's not override GetNeighbours -- let's get them all from the grid server 149 // Let's not override GetNeighbours -- let's get them all from the grid server
149 150
150 public override SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 151 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
151 { 152 {
152 SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); 153 GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
153 if (rinfo == null) 154 if (rinfo == null)
154 rinfo = base.GetRegionByUUID(scopeID, regionID); 155 rinfo = base.GetRegionByUUID(scopeID, regionID);
155 156
156 return rinfo; 157 return rinfo;
157 } 158 }
158 159
159 public override SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 160 public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
160 { 161 {
161 SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); 162 GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
162 if (rinfo == null) 163 if (rinfo == null)
163 rinfo = base.GetRegionByPosition(scopeID, x, y); 164 rinfo = base.GetRegionByPosition(scopeID, x, y);
164 165
165 return rinfo; 166 return rinfo;
166 } 167 }
167 168
168 public override SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 169 public override GridRegion GetRegionByName(UUID scopeID, string regionName)
169 { 170 {
170 SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); 171 GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
171 if (rinfo == null) 172 if (rinfo == null)
172 rinfo = base.GetRegionByName(scopeID, regionName); 173 rinfo = base.GetRegionByName(scopeID, regionName);
173 174
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index 39c0584..e72c2eb 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -38,6 +38,7 @@ using System.Xml.Serialization;
38using System.Collections.Generic; 38using System.Collections.Generic;
39using OpenSim.Server.Base; 39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Framework; 42using OpenSim.Framework;
42using OpenSim.Framework.Servers.HttpServer; 43using OpenSim.Framework.Servers.HttpServer;
43using OpenMetaverse; 44using OpenMetaverse;
@@ -117,7 +118,7 @@ namespace OpenSim.Server.Handlers.Grid
117 Dictionary<string, object> rinfoData = new Dictionary<string, object>(); 118 Dictionary<string, object> rinfoData = new Dictionary<string, object>();
118 foreach (KeyValuePair<string, string> kvp in request) 119 foreach (KeyValuePair<string, string> kvp in request)
119 rinfoData[kvp.Key] = kvp.Value; 120 rinfoData[kvp.Key] = kvp.Value;
120 SimpleRegionInfo rinfo = new SimpleRegionInfo(rinfoData); 121 GridRegion rinfo = new GridRegion(rinfoData);
121 122
122 bool result = m_GridService.RegisterRegion(scopeID, rinfo); 123 bool result = m_GridService.RegisterRegion(scopeID, rinfo);
123 124
@@ -158,11 +159,11 @@ namespace OpenSim.Server.Handlers.Grid
158 else 159 else
159 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); 160 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
160 161
161 List<SimpleRegionInfo> rinfos = m_GridService.GetNeighbours(scopeID, regionID); 162 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
162 163
163 Dictionary<string, object> result = new Dictionary<string, object>(); 164 Dictionary<string, object> result = new Dictionary<string, object>();
164 int i = 0; 165 int i = 0;
165 foreach (SimpleRegionInfo rinfo in rinfos) 166 foreach (GridRegion rinfo in rinfos)
166 { 167 {
167 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); 168 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
168 result["region" + i] = rinfoDict; 169 result["region" + i] = rinfoDict;
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index 1962bcf..0a867db 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer; 36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
39using OpenMetaverse; 40using OpenMetaverse;
40 41
@@ -85,7 +86,7 @@ namespace OpenSim.Services.Connectors
85 86
86 #region IGridService 87 #region IGridService
87 88
88 public virtual bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
89 { 90 {
90 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); 91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
91 Dictionary<string, string> sendData = new Dictionary<string,string>(); 92 Dictionary<string, string> sendData = new Dictionary<string,string>();
@@ -128,7 +129,7 @@ namespace OpenSim.Services.Connectors
128 return false; 129 return false;
129 } 130 }
130 131
131 public virtual List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 132 public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
132 { 133 {
133 Dictionary<string, string> sendData = new Dictionary<string, string>(); 134 Dictionary<string, string> sendData = new Dictionary<string, string>();
134 135
@@ -143,7 +144,7 @@ namespace OpenSim.Services.Connectors
143 144
144 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 145 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
145 146
146 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 147 List<GridRegion> rinfos = new List<GridRegion>();
147 if (replyData != null) 148 if (replyData != null)
148 { 149 {
149 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 150 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@@ -151,7 +152,7 @@ namespace OpenSim.Services.Connectors
151 { 152 {
152 if (r is Dictionary<string, object>) 153 if (r is Dictionary<string, object>)
153 { 154 {
154 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 155 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
155 rinfos.Add(rinfo); 156 rinfos.Add(rinfo);
156 } 157 }
157 else 158 else
@@ -166,7 +167,7 @@ namespace OpenSim.Services.Connectors
166 return rinfos; 167 return rinfos;
167 } 168 }
168 169
169 public virtual SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 170 public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
170 { 171 {
171 Dictionary<string, string> sendData = new Dictionary<string, string>(); 172 Dictionary<string, string> sendData = new Dictionary<string, string>();
172 173
@@ -181,11 +182,11 @@ namespace OpenSim.Services.Connectors
181 182
182 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 183 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
183 184
184 SimpleRegionInfo rinfo = null; 185 GridRegion rinfo = null;
185 if ((replyData != null) && (replyData["result"] != null)) 186 if ((replyData != null) && (replyData["result"] != null))
186 { 187 {
187 if (replyData["result"] is Dictionary<string, object>) 188 if (replyData["result"] is Dictionary<string, object>)
188 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 189 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
189 else 190 else
190 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", 191 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response",
191 scopeID, regionID); 192 scopeID, regionID);
@@ -197,7 +198,7 @@ namespace OpenSim.Services.Connectors
197 return rinfo; 198 return rinfo;
198 } 199 }
199 200
200 public virtual SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 201 public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
201 { 202 {
202 Dictionary<string, string> sendData = new Dictionary<string, string>(); 203 Dictionary<string, string> sendData = new Dictionary<string, string>();
203 204
@@ -213,11 +214,11 @@ namespace OpenSim.Services.Connectors
213 214
214 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 215 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
215 216
216 SimpleRegionInfo rinfo = null; 217 GridRegion rinfo = null;
217 if ((replyData != null) && (replyData["result"] != null)) 218 if ((replyData != null) && (replyData["result"] != null))
218 { 219 {
219 if (replyData["result"] is Dictionary<string, object>) 220 if (replyData["result"] is Dictionary<string, object>)
220 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 221 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
221 else 222 else
222 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", 223 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
223 scopeID, x, y); 224 scopeID, x, y);
@@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors
229 return rinfo; 230 return rinfo;
230 } 231 }
231 232
232 public virtual SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 233 public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
233 { 234 {
234 Dictionary<string, string> sendData = new Dictionary<string, string>(); 235 Dictionary<string, string> sendData = new Dictionary<string, string>();
235 236
@@ -244,11 +245,11 @@ namespace OpenSim.Services.Connectors
244 245
245 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 246 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
246 247
247 SimpleRegionInfo rinfo = null; 248 GridRegion rinfo = null;
248 if ((replyData != null) && (replyData["result"] != null)) 249 if ((replyData != null) && (replyData["result"] != null))
249 { 250 {
250 if (replyData["result"] is Dictionary<string, object>) 251 if (replyData["result"] is Dictionary<string, object>)
251 rinfo = new SimpleRegionInfo((Dictionary<string, object>)replyData["result"]); 252 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
252 else 253 else
253 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", 254 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response",
254 scopeID, regionName); 255 scopeID, regionName);
@@ -260,7 +261,7 @@ namespace OpenSim.Services.Connectors
260 return rinfo; 261 return rinfo;
261 } 262 }
262 263
263 public virtual List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 264 public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
264 { 265 {
265 Dictionary<string, string> sendData = new Dictionary<string, string>(); 266 Dictionary<string, string> sendData = new Dictionary<string, string>();
266 267
@@ -276,7 +277,7 @@ namespace OpenSim.Services.Connectors
276 277
277 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 278 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
278 279
279 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 280 List<GridRegion> rinfos = new List<GridRegion>();
280 if (replyData != null) 281 if (replyData != null)
281 { 282 {
282 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 283 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@@ -284,7 +285,7 @@ namespace OpenSim.Services.Connectors
284 { 285 {
285 if (r is Dictionary<string, object>) 286 if (r is Dictionary<string, object>)
286 { 287 {
287 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 288 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
288 rinfos.Add(rinfo); 289 rinfos.Add(rinfo);
289 } 290 }
290 else 291 else
@@ -299,7 +300,7 @@ namespace OpenSim.Services.Connectors
299 return rinfos; 300 return rinfos;
300 } 301 }
301 302
302 public virtual List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 303 public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
303 { 304 {
304 Dictionary<string, string> sendData = new Dictionary<string, string>(); 305 Dictionary<string, string> sendData = new Dictionary<string, string>();
305 306
@@ -317,7 +318,7 @@ namespace OpenSim.Services.Connectors
317 318
318 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 319 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
319 320
320 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 321 List<GridRegion> rinfos = new List<GridRegion>();
321 if (replyData != null) 322 if (replyData != null)
322 { 323 {
323 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 324 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
@@ -325,7 +326,7 @@ namespace OpenSim.Services.Connectors
325 { 326 {
326 if (r is Dictionary<string, object>) 327 if (r is Dictionary<string, object>)
327 { 328 {
328 SimpleRegionInfo rinfo = new SimpleRegionInfo((Dictionary<string, object>)r); 329 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
329 rinfos.Add(rinfo); 330 rinfos.Add(rinfo);
330 } 331 }
331 else 332 else
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
index 6b0518c..616c2c1 100644
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -33,6 +33,7 @@ using System.Drawing;
33using System.Net; 33using System.Net;
34using System.Reflection; 34using System.Reflection;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 37
37using OpenSim.Framework; 38using OpenSim.Framework;
38 39
@@ -54,7 +55,7 @@ namespace OpenSim.Services.Connectors.Grid
54 m_AssetService = assService; 55 m_AssetService = assService;
55 } 56 }
56 57
57 public UUID LinkRegion(SimpleRegionInfo info, out ulong realHandle) 58 public UUID LinkRegion(GridRegion info, out ulong realHandle)
58 { 59 {
59 UUID uuid = UUID.Zero; 60 UUID uuid = UUID.Zero;
60 realHandle = 0; 61 realHandle = 0;
@@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors.Grid
114 return uuid; 115 return uuid;
115 } 116 }
116 117
117 public void GetMapImage(SimpleRegionInfo info) 118 public void GetMapImage(GridRegion info)
118 { 119 {
119 try 120 try
120 { 121 {
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index b37a51b..cd462ab 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Services.GridService 41namespace OpenSim.Services.GridService
@@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService
48 public GridService(IConfigSource config) 49 public GridService(IConfigSource config)
49 : base(config) 50 : base(config)
50 { 51 {
52 m_log.DebugFormat("[GRID SERVICE]: Starting...");
51 MainConsole.Instance.Commands.AddCommand("kfs", false, 53 MainConsole.Instance.Commands.AddCommand("kfs", false,
52 "show digest", 54 "show digest",
53 "show digest <ID>", 55 "show digest <ID>",
@@ -62,7 +64,7 @@ namespace OpenSim.Services.GridService
62 64
63 #region IGridService 65 #region IGridService
64 66
65 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) 67 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
66 { 68 {
67 if (m_Database.Get(regionInfos.RegionID, scopeID) != null) 69 if (m_Database.Get(regionInfos.RegionID, scopeID) != null)
68 { 70 {
@@ -88,9 +90,9 @@ namespace OpenSim.Services.GridService
88 return m_Database.Delete(regionID); 90 return m_Database.Delete(regionID);
89 } 91 }
90 92
91 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 93 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
92 { 94 {
93 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 95 List<GridRegion> rinfos = new List<GridRegion>();
94 RegionData region = m_Database.Get(regionID, scopeID); 96 RegionData region = m_Database.Get(regionID, scopeID);
95 if (region != null) 97 if (region != null)
96 { 98 {
@@ -105,7 +107,7 @@ namespace OpenSim.Services.GridService
105 return rinfos; 107 return rinfos;
106 } 108 }
107 109
108 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 110 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
109 { 111 {
110 RegionData rdata = m_Database.Get(regionID, scopeID); 112 RegionData rdata = m_Database.Get(regionID, scopeID);
111 if (rdata != null) 113 if (rdata != null)
@@ -114,7 +116,7 @@ namespace OpenSim.Services.GridService
114 return null; 116 return null;
115 } 117 }
116 118
117 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 119 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
118 { 120 {
119 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; 121 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
120 int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; 122 int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize;
@@ -125,7 +127,7 @@ namespace OpenSim.Services.GridService
125 return null; 127 return null;
126 } 128 }
127 129
128 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 130 public GridRegion GetRegionByName(UUID scopeID, string regionName)
129 { 131 {
130 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); 132 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID);
131 if ((rdatas != null) && (rdatas.Count > 0)) 133 if ((rdatas != null) && (rdatas.Count > 0))
@@ -134,12 +136,12 @@ namespace OpenSim.Services.GridService
134 return null; 136 return null;
135 } 137 }
136 138
137 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 139 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
138 { 140 {
139 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); 141 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID);
140 142
141 int count = 0; 143 int count = 0;
142 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 144 List<GridRegion> rinfos = new List<GridRegion>();
143 145
144 if (rdatas != null) 146 if (rdatas != null)
145 { 147 {
@@ -153,7 +155,7 @@ namespace OpenSim.Services.GridService
153 return rinfos; 155 return rinfos;
154 } 156 }
155 157
156 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 158 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
157 { 159 {
158 int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; 160 int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
159 int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; 161 int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
@@ -161,7 +163,7 @@ namespace OpenSim.Services.GridService
161 int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; 163 int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
162 164
163 List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); 165 List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID);
164 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 166 List<GridRegion> rinfos = new List<GridRegion>();
165 foreach (RegionData rdata in rdatas) 167 foreach (RegionData rdata in rdatas)
166 rinfos.Add(RegionData2RegionInfo(rdata)); 168 rinfos.Add(RegionData2RegionInfo(rdata));
167 169
@@ -172,7 +174,7 @@ namespace OpenSim.Services.GridService
172 174
173 #region Data structure conversions 175 #region Data structure conversions
174 176
175 protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) 177 protected RegionData RegionInfo2RegionData(GridRegion rinfo)
176 { 178 {
177 RegionData rdata = new RegionData(); 179 RegionData rdata = new RegionData();
178 rdata.posX = (int)rinfo.RegionLocX; 180 rdata.posX = (int)rinfo.RegionLocX;
@@ -184,11 +186,11 @@ namespace OpenSim.Services.GridService
184 return rdata; 186 return rdata;
185 } 187 }
186 188
187 protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) 189 protected GridRegion RegionData2RegionInfo(RegionData rdata)
188 { 190 {
189 SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); 191 GridRegion rinfo = new GridRegion(rdata.Data);
190 rinfo.RegionLocX = (uint)rdata.posX; 192 rinfo.RegionLocX = rdata.posX;
191 rinfo.RegionLocY = (uint)rdata.posY; 193 rinfo.RegionLocY = rdata.posY;
192 rinfo.RegionID = rdata.RegionID; 194 rinfo.RegionID = rdata.RegionID;
193 rinfo.RegionName = rdata.RegionName; 195 rinfo.RegionName = rdata.RegionName;
194 196
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs
index 7522e64..444f79b 100644
--- a/OpenSim/Services/GridService/GridServiceBase.cs
+++ b/OpenSim/Services/GridService/GridServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService
68 connString = gridConfig.GetString("ConnectionString", connString); 68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm); 69 realm = gridConfig.GetString("Realm", realm);
70 } 70 }
71 71
72 // 72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 8f6c524..a188f7e 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -25,8 +25,11 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenSim.Framework; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using OpenSim.Framework;
30using OpenMetaverse; 33using OpenMetaverse;
31 34
32namespace OpenSim.Services.Interfaces 35namespace OpenSim.Services.Interfaces
@@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces
39 /// <param name="regionInfos"> </param> 42 /// <param name="regionInfos"> </param>
40 /// <returns></returns> 43 /// <returns></returns>
41 /// <exception cref="System.Exception">Thrown if region registration failed</exception> 44 /// <exception cref="System.Exception">Thrown if region registration failed</exception>
42 bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); 45 bool RegisterRegion(UUID scopeID, GridRegion regionInfos);
43 46
44 /// <summary> 47 /// <summary>
45 /// Deregister a region with the grid service. 48 /// Deregister a region with the grid service.
@@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces
55 /// <param name="x"></param> 58 /// <param name="x"></param>
56 /// <param name="y"></param> 59 /// <param name="y"></param>
57 /// <returns></returns> 60 /// <returns></returns>
58 List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID); 61 List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID);
59 62
60 SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); 63 GridRegion GetRegionByUUID(UUID scopeID, UUID regionID);
61 64
62 /// <summary> 65 /// <summary>
63 /// Get the region at the given position (in meters) 66 /// Get the region at the given position (in meters)
@@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces
66 /// <param name="x"></param> 69 /// <param name="x"></param>
67 /// <param name="y"></param> 70 /// <param name="y"></param>
68 /// <returns></returns> 71 /// <returns></returns>
69 SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); 72 GridRegion GetRegionByPosition(UUID scopeID, int x, int y);
70 73
71 SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); 74 GridRegion GetRegionByName(UUID scopeID, string regionName);
72 75
73 /// <summary> 76 /// <summary>
74 /// Get information about regions starting with the provided name. 77 /// Get information about regions starting with the provided name.
@@ -83,9 +86,237 @@ namespace OpenSim.Services.Interfaces
83 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the 86 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
84 /// grid-server couldn't be contacted or returned an error, return null. 87 /// grid-server couldn't be contacted or returned an error, return null.
85 /// </returns> 88 /// </returns>
86 List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); 89 List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber);
87 90
88 List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); 91 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
89 92
90 } 93 }
94
95 public class GridRegion
96 {
97
98 /// <summary>
99 /// The port by which http communication occurs with the region
100 /// </summary>
101 public uint HttpPort
102 {
103 get { return m_httpPort; }
104 set { m_httpPort = value; }
105 }
106 protected uint m_httpPort;
107
108 /// <summary>
109 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
110 /// </summary>
111 public string ServerURI
112 {
113 get { return m_serverURI; }
114 set { m_serverURI = value; }
115 }
116 protected string m_serverURI;
117
118 public string RegionName
119 {
120 get { return m_regionName; }
121 set { m_regionName = value; }
122 }
123 protected string m_regionName = String.Empty;
124
125 protected bool Allow_Alternate_Ports;
126 public bool m_allow_alternate_ports;
127
128 protected string m_externalHostName;
129
130 protected IPEndPoint m_internalEndPoint;
131
132 public int RegionLocX
133 {
134 get { return m_regionLocX; }
135 set { m_regionLocX = value; }
136 }
137 protected int m_regionLocX;
138
139 public int RegionLocY
140 {
141 get { return m_regionLocY; }
142 set { m_regionLocY = value; }
143 }
144 protected int m_regionLocY;
145
146 public UUID RegionID = UUID.Zero;
147 public UUID ScopeID = UUID.Zero;
148
149 public GridRegion()
150 {
151 }
152
153 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
154 {
155 m_regionLocX = regionLocX;
156 m_regionLocY = regionLocY;
157
158 m_internalEndPoint = internalEndPoint;
159 m_externalHostName = externalUri;
160 }
161
162 public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port)
163 {
164 m_regionLocX = regionLocX;
165 m_regionLocY = regionLocY;
166
167 m_externalHostName = externalUri;
168
169 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
170 }
171
172 public GridRegion(uint xcell, uint ycell)
173 {
174 m_regionLocX = (int)(xcell * Constants.RegionSize);
175 m_regionLocY = (int)(ycell * Constants.RegionSize);
176 }
177
178 public GridRegion(RegionInfo ConvertFrom)
179 {
180 m_regionName = ConvertFrom.RegionName;
181 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize);
182 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize);
183 m_internalEndPoint = ConvertFrom.InternalEndPoint;
184 m_externalHostName = ConvertFrom.ExternalHostName;
185 m_httpPort = ConvertFrom.HttpPort;
186 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
187 RegionID = UUID.Zero;
188 ServerURI = ConvertFrom.ServerURI;
189 }
190
191
192 /// <value>
193 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
194 ///
195 /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
196 /// </value>
197 public IPEndPoint ExternalEndPoint
198 {
199 get
200 {
201 // Old one defaults to IPv6
202 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
203
204 IPAddress ia = null;
205 // If it is already an IP, don't resolve it - just return directly
206 if (IPAddress.TryParse(m_externalHostName, out ia))
207 return new IPEndPoint(ia, m_internalEndPoint.Port);
208
209 // Reset for next check
210 ia = null;
211 try
212 {
213 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
214 {
215 if (ia == null)
216 ia = Adr;
217
218 if (Adr.AddressFamily == AddressFamily.InterNetwork)
219 {
220 ia = Adr;
221 break;
222 }
223 }
224 }
225 catch (SocketException e)
226 {
227 throw new Exception(
228 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
229 e + "' attached to this exception", e);
230 }
231
232 return new IPEndPoint(ia, m_internalEndPoint.Port);
233 }
234
235 set { m_externalHostName = value.ToString(); }
236 }
237
238 public string ExternalHostName
239 {
240 get { return m_externalHostName; }
241 set { m_externalHostName = value; }
242 }
243
244 public IPEndPoint InternalEndPoint
245 {
246 get { return m_internalEndPoint; }
247 set { m_internalEndPoint = value; }
248 }
249
250 public ulong RegionHandle
251 {
252 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
253 }
254
255 public int getInternalEndPointPort()
256 {
257 return m_internalEndPoint.Port;
258 }
259
260 public Dictionary<string, object> ToKeyValuePairs()
261 {
262 Dictionary<string, object> kvp = new Dictionary<string, object>();
263 kvp["uuid"] = RegionID.ToString();
264 kvp["locX"] = RegionLocX.ToString();
265 kvp["locY"] = RegionLocY.ToString();
266 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
267 kvp["external_port"] = ExternalEndPoint.Port.ToString();
268 kvp["external_host_name"] = ExternalHostName;
269 kvp["http_port"] = HttpPort.ToString();
270 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
271 kvp["internal_port"] = InternalEndPoint.Port.ToString();
272 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
273 kvp["server_uri"] = ServerURI;
274
275 return kvp;
276 }
277
278 public GridRegion(Dictionary<string, object> kvp)
279 {
280 if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null))
281 {
282 int port = 0;
283 Int32.TryParse((string)kvp["external_port"], out port);
284 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port);
285 ExternalEndPoint = ep;
286 }
287 else
288 ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
289
290 if (kvp["external_host_name"] != null)
291 ExternalHostName = (string)kvp["external_host_name"];
292
293 if (kvp["http_port"] != null)
294 {
295 UInt32 port = 0;
296 UInt32.TryParse((string)kvp["http_port"], out port);
297 HttpPort = port;
298 }
299
300 if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null))
301 {
302 int port = 0;
303 Int32.TryParse((string)kvp["internal_port"], out port);
304 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port);
305 InternalEndPoint = ep;
306 }
307 else
308 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
309
310 if (kvp["alternate_ports"] != null)
311 {
312 bool alts = false;
313 Boolean.TryParse((string)kvp["alternate_ports"], out alts);
314 m_allow_alternate_ports = alts;
315 }
316
317 if (kvp["server_uri"] != null)
318 ServerURI = (string)kvp["server_uri"];
319 }
320 }
321
91} 322}