aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs10
-rw-r--r--OpenSim/Framework/Communications/Clients/RegionClient.cs16
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs5
-rw-r--r--OpenSim/Framework/IRegionCommsListener.cs3
-rw-r--r--OpenSim/Framework/IScene.cs2
-rw-r--r--OpenSim/Framework/NetworkServersInfo.cs3
-rw-r--r--OpenSim/Framework/RegionCommsListener.cs13
-rw-r--r--OpenSim/Framework/Util.cs26
-rw-r--r--OpenSim/Region/Application/HGCommands.cs215
-rw-r--r--OpenSim/Region/Application/OpenSim.cs5
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs2
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs3
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs9
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs3
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServices.cs1024
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs159
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs259
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs2
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs410
-rw-r--r--OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs2
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs937
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs18
-rw-r--r--OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs208
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs32
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs6
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs297
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs54
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs52
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs19
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs63
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs30
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs98
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs232
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs181
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs358
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs25
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs124
-rw-r--r--OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs10
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs92
-rw-r--r--OpenSim/Services/Connectors/Land/LandServiceConnector.cs13
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs22
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs41
-rw-r--r--OpenSim/Services/Interfaces/IHyperlink.cs49
-rw-r--r--OpenSim/Services/Interfaces/INeighbourService.cs3
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs2
63 files changed, 1275 insertions, 4051 deletions
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
index 6a66116..cd93bea 100644
--- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs
@@ -144,7 +144,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
144 // We are in grid mode 144 // We are in grid mode
145 InitialiseHGGridServices(libraryRootFolder); 145 InitialiseHGGridServices(libraryRootFolder);
146 } 146 }
147 HGCommands.HGServices = HGServices;
148 } 147 }
149 148
150 protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder) 149 protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder)
@@ -188,18 +187,11 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
188 187
189 protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder) 188 protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder)
190 { 189 {
191 HGGridServicesStandalone gridService
192 = new HGGridServicesStandalone(
193 m_openSim.NetServersInfo, m_httpServer, m_openSim.SceneManager);
194
195 m_commsManager 190 m_commsManager
196 = new HGCommunicationsStandalone( 191 = new HGCommunicationsStandalone(
197 m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, 192 m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer,
198 gridService,
199 libraryRootFolder, false); 193 libraryRootFolder, false);
200 194
201 HGServices = gridService;
202
203 CreateGridInfoService(); 195 CreateGridInfoService();
204 } 196 }
205 197
@@ -210,8 +202,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
210 m_openSim.NetServersInfo, 202 m_openSim.NetServersInfo,
211 m_openSim.SceneManager, libraryRootFolder); 203 m_openSim.SceneManager, libraryRootFolder);
212 204
213 HGServices = ((HGCommunicationsGridMode) m_commsManager).HGServices;
214
215 m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler()); 205 m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler());
216 m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim)); 206 m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim));
217 if (m_openSim.userStatsURI != String.Empty) 207 if (m_openSim.userStatsURI != String.Empty)
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs
index 73e2db0..3419ce2 100644
--- a/OpenSim/Framework/Communications/Clients/RegionClient.cs
+++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs
@@ -35,6 +35,8 @@ using System.Text;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37 37
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39
38using log4net; 40using log4net;
39 41
40namespace OpenSim.Framework.Communications.Clients 42namespace OpenSim.Framework.Communications.Clients
@@ -43,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients
43 { 45 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 47
46 public bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit, string authKey, out string reason) 48 public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason)
47 { 49 {
48 reason = String.Empty; 50 reason = String.Empty;
49 51
@@ -166,7 +168,7 @@ namespace OpenSim.Framework.Communications.Clients
166 168
167 } 169 }
168 170
169 public bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) 171 public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData)
170 { 172 {
171 // Eventually, we want to use a caps url instead of the agentID 173 // Eventually, we want to use a caps url instead of the agentID
172 string uri = string.Empty; 174 string uri = string.Empty;
@@ -260,7 +262,7 @@ namespace OpenSim.Framework.Communications.Clients
260 return true; 262 return true;
261 } 263 }
262 264
263 public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) 265 public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent)
264 { 266 {
265 agent = null; 267 agent = null;
266 // Eventually, we want to use a caps url instead of the agentID 268 // Eventually, we want to use a caps url instead of the agentID
@@ -348,7 +350,7 @@ namespace OpenSim.Framework.Communications.Clients
348 } 350 }
349 351
350 352
351 public bool DoCloseAgentCall(RegionInfo region, UUID id) 353 public bool DoCloseAgentCall(GridRegion region, UUID id)
352 { 354 {
353 string uri = string.Empty; 355 string uri = string.Empty;
354 try 356 try
@@ -391,7 +393,7 @@ namespace OpenSim.Framework.Communications.Clients
391 return true; 393 return true;
392 } 394 }
393 395
394 public bool DoCreateObjectCall(RegionInfo region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) 396 public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing)
395 { 397 {
396 ulong regionHandle = GetRegionHandle(region.RegionHandle); 398 ulong regionHandle = GetRegionHandle(region.RegionHandle);
397 string uri 399 string uri
@@ -474,7 +476,7 @@ namespace OpenSim.Framework.Communications.Clients
474 476
475 } 477 }
476 478
477 public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID) 479 public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID)
478 { 480 {
479 ulong regionHandle = GetRegionHandle(region.RegionHandle); 481 ulong regionHandle = GetRegionHandle(region.RegionHandle);
480 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; 482 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/";
@@ -646,7 +648,7 @@ namespace OpenSim.Framework.Communications.Clients
646 return false; 648 return false;
647 } 649 }
648 650
649 public virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) 651 public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
650 { 652 {
651 } 653 }
652 654
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index e9a6adb..9f377a6 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -59,11 +59,6 @@ namespace OpenSim.Framework.Communications
59 } 59 }
60 protected IMessagingService m_messageService; 60 protected IMessagingService m_messageService;
61 61
62 public IGridServices GridService
63 {
64 get { return m_gridService; }
65 }
66 protected IGridServices m_gridService;
67 62
68 public UserProfileCacheService UserProfileCacheService 63 public UserProfileCacheService UserProfileCacheService
69 { 64 {
diff --git a/OpenSim/Framework/IRegionCommsListener.cs b/OpenSim/Framework/IRegionCommsListener.cs
index ba4c616..307c6bc 100644
--- a/OpenSim/Framework/IRegionCommsListener.cs
+++ b/OpenSim/Framework/IRegionCommsListener.cs
@@ -46,8 +46,6 @@ namespace OpenSim.Framework
46 46
47 public delegate bool CloseAgentConnection(UUID agentID); 47 public delegate bool CloseAgentConnection(UUID agentID);
48 48
49 public delegate bool RegionUp(RegionInfo region);
50
51 public delegate bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData); 49 public delegate bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData);
52 50
53 public delegate void LogOffUser(UUID agentID, UUID regionSecret, string message); 51 public delegate void LogOffUser(UUID agentID, UUID regionSecret, string message);
@@ -65,7 +63,6 @@ namespace OpenSim.Framework
65 event AcknowledgePrimCross OnAcknowledgePrimCrossed; 63 event AcknowledgePrimCross OnAcknowledgePrimCrossed;
66 event UpdateNeighbours OnNeighboursUpdate; 64 event UpdateNeighbours OnNeighboursUpdate;
67 event CloseAgentConnection OnCloseAgentConnection; 65 event CloseAgentConnection OnCloseAgentConnection;
68 event RegionUp OnRegionUp;
69 event ChildAgentUpdate OnChildAgentUpdate; 66 event ChildAgentUpdate OnChildAgentUpdate;
70 event LogOffUser OnLogOffUser; 67 event LogOffUser OnLogOffUser;
71 event GetLandData OnGetLandData; 68 event GetLandData OnGetLandData;
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index 2e2c703..d61e08c 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -74,7 +74,7 @@ namespace OpenSim.Framework
74 void CloseAllAgents(uint circuitcode); 74 void CloseAllAgents(uint circuitcode);
75 75
76 void Restart(int seconds); 76 void Restart(int seconds);
77 bool OtherRegionUp(RegionInfo thisRegion); 77 //RegionInfo OtherRegionUp(RegionInfo thisRegion);
78 78
79 string GetSimulatorVersion(); 79 string GetSimulatorVersion();
80 80
diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs
index 3b00af3..7e66742 100644
--- a/OpenSim/Framework/NetworkServersInfo.cs
+++ b/OpenSim/Framework/NetworkServersInfo.cs
@@ -102,8 +102,7 @@ namespace OpenSim.Framework
102 ConfigSettings.DefaultInventoryServerHttpPort.ToString()); 102 ConfigSettings.DefaultInventoryServerHttpPort.ToString());
103 secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true); 103 secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true);
104 104
105 MessagingURL = config.Configs["Network"].GetString("messaging_server_url", 105 MessagingURL = config.Configs["Network"].GetString("messaging_server_url", string.Empty);
106 "http://127.0.0.1:" + ConfigSettings.DefaultMessageServerHttpPort);
107 } 106 }
108 } 107 }
109} 108}
diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs
index 016c78c..90200d6 100644
--- a/OpenSim/Framework/RegionCommsListener.cs
+++ b/OpenSim/Framework/RegionCommsListener.cs
@@ -47,7 +47,6 @@ namespace OpenSim.Framework
47 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser 47 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
48 private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate; 48 private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
49 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 49 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
50 private RegionUp handlerRegionUp = null; // OnRegionUp;
51 private LogOffUser handlerLogOffUser = null; 50 private LogOffUser handlerLogOffUser = null;
52 private GetLandData handlerGetLandData = null; 51 private GetLandData handlerGetLandData = null;
53 52
@@ -62,7 +61,6 @@ namespace OpenSim.Framework
62 public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed; 61 public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed;
63 public event AcknowledgePrimCross OnAcknowledgePrimCrossed; 62 public event AcknowledgePrimCross OnAcknowledgePrimCrossed;
64 public event CloseAgentConnection OnCloseAgentConnection; 63 public event CloseAgentConnection OnCloseAgentConnection;
65 public event RegionUp OnRegionUp;
66 public event ChildAgentUpdate OnChildAgentUpdate; 64 public event ChildAgentUpdate OnChildAgentUpdate;
67 public event LogOffUser OnLogOffUser; 65 public event LogOffUser OnLogOffUser;
68 public event GetLandData OnGetLandData; 66 public event GetLandData OnGetLandData;
@@ -108,17 +106,6 @@ namespace OpenSim.Framework
108 return false; 106 return false;
109 } 107 }
110 108
111 public virtual bool TriggerRegionUp(RegionInfo region)
112 {
113 handlerRegionUp = OnRegionUp;
114 if (handlerRegionUp != null)
115 {
116 handlerRegionUp(region);
117 return true;
118 }
119 return false;
120 }
121
122 public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData) 109 public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
123 { 110 {
124 handlerChildAgentUpdate = OnChildAgentUpdate; 111 handlerChildAgentUpdate = OnChildAgentUpdate;
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 45b5a10..a28a617 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1203,6 +1203,32 @@ namespace OpenSim.Framework
1203 return found.ToArray(); 1203 return found.ToArray();
1204 } 1204 }
1205 1205
1206 public static string ServerURI(string uri)
1207 {
1208 if (uri == string.Empty)
1209 return string.Empty;
1210
1211 // Get rid of eventual slashes at the end
1212 uri = uri.TrimEnd('/');
1213
1214 IPAddress ipaddr1 = null;
1215 string port1 = "";
1216 try
1217 {
1218 ipaddr1 = Util.GetHostFromURL(uri);
1219 }
1220 catch { }
1221
1222 try
1223 {
1224 port1 = uri.Split(new char[] { ':' })[2];
1225 }
1226 catch { }
1227
1228 // We tried our best to convert the domain names to IP addresses
1229 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
1230 }
1231
1206 #region FireAndForget Threading Pattern 1232 #region FireAndForget Threading Pattern
1207 1233
1208 public static void FireAndForget(System.Threading.WaitCallback callback) 1234 public static void FireAndForget(System.Threading.WaitCallback callback)
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs
index 1786e54..f503db7 100644
--- a/OpenSim/Region/Application/HGCommands.cs
+++ b/OpenSim/Region/Application/HGCommands.cs
@@ -43,16 +43,11 @@ namespace OpenSim
43 public class HGCommands 43 public class HGCommands
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 public static IHyperlink HGServices = null;
47
48 private static uint m_autoMappingX = 0;
49 private static uint m_autoMappingY = 0;
50 private static bool m_enableAutoMapping = false;
51 46
52 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, 47 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
53 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) 48 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
54 { 49 {
55 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); 50 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);
56 51
57 return 52 return
58 new HGScene( 53 new HGScene(
@@ -61,213 +56,5 @@ namespace OpenSim
61 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); 56 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
62 } 57 }
63 58
64 public static void RunHGCommand(string command, string[] cmdparams, Scene scene)
65 {
66 if (command.Equals("link-mapping"))
67 {
68 if (cmdparams.Length == 2)
69 {
70 try
71 {
72 m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
73 m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
74 m_enableAutoMapping = true;
75 }
76 catch (Exception)
77 {
78 m_autoMappingX = 0;
79 m_autoMappingY = 0;
80 m_enableAutoMapping = false;
81 }
82 }
83 }
84 else if (command.Equals("link-region"))
85 {
86 if (cmdparams.Length < 3)
87 {
88 if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
89 {
90 LoadXmlLinkFile(cmdparams, scene);
91 }
92 else
93 {
94 LinkRegionCmdUsage();
95 }
96 return;
97 }
98
99 if (cmdparams[2].Contains(":"))
100 {
101 // New format
102 uint xloc, yloc;
103 string mapName;
104 try
105 {
106 xloc = Convert.ToUInt32(cmdparams[0]);
107 yloc = Convert.ToUInt32(cmdparams[1]);
108 mapName = cmdparams[2];
109 if (cmdparams.Length > 3)
110 for (int i = 3; i < cmdparams.Length; i++)
111 mapName += " " + cmdparams[i];
112
113 m_log.Info(">> MapName: " + mapName);
114 //internalPort = Convert.ToUInt32(cmdparams[4]);
115 //remotingPort = Convert.ToUInt32(cmdparams[5]);
116 }
117 catch (Exception e)
118 {
119 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
120 LinkRegionCmdUsage();
121 return;
122 }
123
124 HGHyperlink.TryLinkRegionToCoords(scene, null, mapName, xloc, yloc);
125 }
126 else
127 {
128 // old format
129 RegionInfo regInfo;
130 uint xloc, yloc;
131 uint externalPort;
132 string externalHostName;
133 try
134 {
135 xloc = Convert.ToUInt32(cmdparams[0]);
136 yloc = Convert.ToUInt32(cmdparams[1]);
137 externalPort = Convert.ToUInt32(cmdparams[3]);
138 externalHostName = cmdparams[2];
139 //internalPort = Convert.ToUInt32(cmdparams[4]);
140 //remotingPort = Convert.ToUInt32(cmdparams[5]);
141 }
142 catch (Exception e)
143 {
144 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
145 LinkRegionCmdUsage();
146 return;
147 }
148
149 //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
150 if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
151 {
152 if (cmdparams.Length >= 5)
153 {
154 regInfo.RegionName = "";
155 for (int i = 4; i < cmdparams.Length; i++)
156 regInfo.RegionName += cmdparams[i] + " ";
157 }
158 }
159 }
160 return;
161 }
162 else if (command.Equals("unlink-region"))
163 {
164 if (cmdparams.Length < 1)
165 {
166 UnlinkRegionCmdUsage();
167 return;
168 }
169 if (HGHyperlink.TryUnlinkRegion(scene, cmdparams[0]))
170 m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
171 else
172 m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
173 }
174 }
175
176 private static void LoadXmlLinkFile(string[] cmdparams, Scene scene)
177 {
178 //use http://www.hgurl.com/hypergrid.xml for test
179 try
180 {
181 XmlReader r = XmlReader.Create(cmdparams[0]);
182 XmlConfigSource cs = new XmlConfigSource(r);
183 string[] excludeSections = null;
184
185 if (cmdparams.Length == 2)
186 {
187 if (cmdparams[1].ToLower().StartsWith("excludelist:"))
188 {
189 string excludeString = cmdparams[1].ToLower();
190 excludeString = excludeString.Remove(0, 12);
191 char[] splitter = {';'};
192
193 excludeSections = excludeString.Split(splitter);
194 }
195 }
196
197 for (int i = 0; i < cs.Configs.Count; i++)
198 {
199 bool skip = false;
200 if ((excludeSections != null) && (excludeSections.Length > 0))
201 {
202 for (int n = 0; n < excludeSections.Length; n++)
203 {
204 if (excludeSections[n] == cs.Configs[i].Name.ToLower())
205 {
206 skip = true;
207 break;
208 }
209 }
210 }
211 if (!skip)
212 {
213 ReadLinkFromConfig(cs.Configs[i], scene);
214 }
215 }
216 }
217 catch (Exception e)
218 {
219 m_log.Error(e.ToString());
220 }
221 }
222
223
224 private static void ReadLinkFromConfig(IConfig config, Scene scene)
225 {
226 RegionInfo regInfo;
227 uint xloc, yloc;
228 uint externalPort;
229 string externalHostName;
230 uint realXLoc, realYLoc;
231
232 xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
233 yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
234 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
235 externalHostName = config.GetString("externalHostName", "");
236 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
237 realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
238
239 if (m_enableAutoMapping)
240 {
241 xloc = (uint) ((xloc%100) + m_autoMappingX);
242 yloc = (uint) ((yloc%100) + m_autoMappingY);
243 }
244
245 if (((realXLoc == 0) && (realYLoc == 0)) ||
246 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
247 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
248 {
249 if (
250 HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort,
251 externalHostName, out regInfo))
252 {
253 regInfo.RegionName = config.GetString("localName", "");
254 }
255 }
256 }
257
258
259 private static void LinkRegionCmdUsage()
260 {
261 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
262 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
263 m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
264 }
265
266 private static void UnlinkRegionCmdUsage()
267 {
268 m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
269 m_log.Info("Usage: unlink-region <LocalName>");
270 }
271
272 } 59 }
273} 60}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index e9c9dc1..c0bdc1e 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -755,11 +755,6 @@ namespace OpenSim
755 } 755 }
756 break; 756 break;
757 757
758 case "link-region":
759 case "unlink-region":
760 case "link-mapping":
761 HGCommands.RunHGCommand(command, cmdparams, m_sceneManager.CurrentOrFirstScene);
762 break;
763 } 758 }
764 } 759 }
765 760
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 4d13e83..821de35 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -399,7 +399,7 @@ namespace OpenSim
399 } 399 }
400 catch (Exception e) 400 catch (Exception e)
401 { 401 {
402 m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e); 402 m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e.StackTrace);
403 403
404 // Carrying on now causes a lot of confusion down the 404 // Carrying on now causes a lot of confusion down the
405 // line - we need to get the user's attention 405 // line - we need to get the user's attention
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs
index c831f68..34c21aa 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/MockScene.cs
@@ -28,6 +28,7 @@
28using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenSim.Region.Framework.Scenes; 30using OpenSim.Region.Framework.Scenes;
31using GridRegion = OpenSim.Services.Interfaces.GridRegion;
31 32
32namespace OpenSim.Region.ClientStack.LindenUDP.Tests 33namespace OpenSim.Region.ClientStack.LindenUDP.Tests
33{ 34{
@@ -58,7 +59,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
58 59
59 public override void RemoveClient(UUID agentID) {} 60 public override void RemoveClient(UUID agentID) {}
60 public override void CloseAllAgents(uint circuitcode) {} 61 public override void CloseAllAgents(uint circuitcode) {}
61 public override bool OtherRegionUp(RegionInfo thisRegion) { return false; } 62 public override void OtherRegionUp(GridRegion otherRegion) { }
62 63
63 /// <summary> 64 /// <summary>
64 /// Doesn't really matter what the call is - we're using this to test that a packet has actually been received 65 /// Doesn't really matter what the call is - we're using this to test that a packet has actually been received
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
index 80f2e79..002ea17 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs
@@ -40,21 +40,12 @@ namespace OpenSim.Region.Communications.Hypergrid
40{ 40{
41 public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1 41 public class HGCommunicationsGridMode : CommunicationsManager // CommunicationsOGS1
42 { 42 {
43 IHyperlink m_osw = null;
44 public IHyperlink HGServices
45 {
46 get { return m_osw; }
47 }
48 43
49 public HGCommunicationsGridMode( 44 public HGCommunicationsGridMode(
50 NetworkServersInfo serversInfo, 45 NetworkServersInfo serversInfo,
51 SceneManager sman, LibraryRootFolder libraryRootFolder) 46 SceneManager sman, LibraryRootFolder libraryRootFolder)
52 : base(serversInfo, libraryRootFolder) 47 : base(serversInfo, libraryRootFolder)
53 { 48 {
54 // From constructor at CommunicationsOGS1
55 HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, sman, m_userProfileCacheService);
56 m_gridService = gridInterComms;
57 m_osw = gridInterComms;
58 49
59 HGUserServices userServices = new HGUserServices(this); 50 HGUserServices userServices = new HGUserServices(this);
60 // This plugin arrangement could eventually be configurable rather than hardcoded here. 51 // This plugin arrangement could eventually be configurable rather than hardcoded here.
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
index e4e12d4..f5126ca 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs
@@ -44,7 +44,6 @@ namespace OpenSim.Region.Communications.Hypergrid
44 ConfigSettings configSettings, 44 ConfigSettings configSettings,
45 NetworkServersInfo serversInfo, 45 NetworkServersInfo serversInfo,
46 BaseHttpServer httpServer, 46 BaseHttpServer httpServer,
47 HGGridServices gridService,
48 LibraryRootFolder libraryRootFolder, 47 LibraryRootFolder libraryRootFolder,
49 bool dumpAssetsToFile) 48 bool dumpAssetsToFile)
50 : base(serversInfo, libraryRootFolder) 49 : base(serversInfo, libraryRootFolder)
@@ -64,8 +63,6 @@ namespace OpenSim.Region.Communications.Hypergrid
64 m_avatarService = hgUserService; 63 m_avatarService = hgUserService;
65 m_messageService = hgUserService; 64 m_messageService = hgUserService;
66 65
67 gridService.UserProfileCache = m_userProfileCacheService;
68 m_gridService = gridService;
69 } 66 }
70 } 67 }
71} 68}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
deleted file mode 100644
index 54cde0f..0000000
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
+++ /dev/null
@@ -1,1024 +0,0 @@
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
28
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Drawing;
33using System.Net;
34using System.Net.Sockets;
35using System.Reflection;
36using System.Runtime.Remoting;
37using System.Security.Authentication;
38using log4net;
39using Nwc.XmlRpc;
40using OpenMetaverse;
41using OpenMetaverse.Imaging;
42using OpenSim.Framework;
43using OpenSim.Framework.Communications;
44using OpenSim.Framework.Communications.Cache;
45using OpenSim.Framework.Servers;
46using OpenSim.Framework.Servers.HttpServer;
47using OpenSim.Region.Communications.OGS1;
48using OpenSim.Region.Framework.Scenes;
49using OpenSim.Services.Interfaces;
50// using OpenSim.Region.Environment.Modules.Framework;
51
52namespace OpenSim.Region.Communications.Hypergrid
53{
54 /// <summary>
55 /// This class encapsulates the main hypergrid functions related to creating and managing
56 /// hyperlinks, as well as processing all the inter-region comms between a region and
57 /// an hyperlinked region.
58 /// </summary>
59 public class HGGridServices : IGridServices, IHyperlink
60 {
61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
62
63
64 public BaseHttpServer httpListener;
65 public NetworkServersInfo serversInfo;
66
67 protected List<RegionInfo> m_regionsOnInstance = new List<RegionInfo>();
68
69 // Hyperlink regions are hyperlinks on the map
70 protected List<RegionInfo> m_hyperlinkRegions = new List<RegionInfo>();
71
72 // Known regions are home regions of visiting foreign users.
73 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
74 // the visitor goes away. They are mapped to X=0 on the map.
75 // This is key-ed on agent ID
76 protected Dictionary<UUID, RegionInfo> m_knownRegions = new Dictionary<UUID, RegionInfo>();
77
78 protected UserProfileCacheService m_userProfileCache;
79 protected SceneManager m_sceneman;
80
81 private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
82
83 public virtual string gdebugRegionName
84 {
85 get { return "Override me"; }
86 set { ; }
87 }
88
89 public string rdebugRegionName
90 {
91 get { return _rdebugRegionName; }
92 set { _rdebugRegionName = value; }
93 }
94 private string _rdebugRegionName = String.Empty;
95
96 public virtual bool RegionLoginsEnabled
97 {
98 get { return true; }
99 set { ; }
100 }
101
102 public UserProfileCacheService UserProfileCache
103 {
104 set { m_userProfileCache = value; }
105 }
106
107 private Random random;
108
109 /// <summary>
110 /// Contructor. Adds "expect_hg_user" and "check" xmlrpc method handlers
111 /// </summary>
112 /// <param name="servers_info"></param>
113 public HGGridServices(NetworkServersInfo servers_info, SceneManager sman)
114 {
115 serversInfo = servers_info;
116 m_sceneman = sman;
117
118 random = new Random();
119
120 MainServer.Instance.AddXmlRPCHandler("link_region", LinkRegionRequest);
121 MainServer.Instance.AddXmlRPCHandler("expect_hg_user", ExpectHGUser);
122
123 HGNetworkServersInfo.Init(servers_info.AssetURL, servers_info.InventoryURL, servers_info.UserURL);
124 }
125
126 // see IGridServices
127 public virtual RegionCommsListener RegisterRegion(RegionInfo regionInfo)
128 {
129 // Region doesn't exist here. Trying to link remote region
130
131 m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
132 regionInfo.RegionID = LinkRegion(regionInfo); // UUID.Random();
133 if (!regionInfo.RegionID.Equals(UUID.Zero))
134 {
135 m_hyperlinkRegions.Add(regionInfo);
136 m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
137
138 //Try get the map image
139 GetMapImage(regionInfo);
140 }
141 else
142 {
143 m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
144 }
145 // Note that these remote regions aren't registered in localBackend, so return null, no local listeners
146 return null;
147 }
148
149 // see IGridServices
150 public virtual bool DeregisterRegion(RegionInfo regionInfo)
151 {
152 if (m_hyperlinkRegions.Contains(regionInfo))
153 {
154 m_hyperlinkRegions.Remove(regionInfo);
155 return true;
156 }
157 foreach (KeyValuePair<UUID, RegionInfo> kvp in m_knownRegions)
158 {
159 if (kvp.Value == regionInfo)
160 {
161 m_knownRegions.Remove(kvp.Key);
162 return true;
163 }
164 }
165 return false;
166 }
167
168 public virtual Dictionary<string, string> GetGridSettings()
169 {
170 Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
171 lock (m_queuedGridSettings)
172 {
173 foreach (string Dictkey in m_queuedGridSettings.Keys)
174 {
175 returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]);
176 }
177
178 m_queuedGridSettings.Clear();
179 }
180
181 return returnGridSettings;
182 }
183
184 // see IGridServices
185 public virtual List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
186 {
187 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
188 foreach (RegionInfo reg in m_hyperlinkRegions)
189 {
190 if (reg.RegionLocX != x || reg.RegionLocY != y)
191 {
192 //m_log.Debug("CommsManager- RequestNeighbours() - found a different region in list, checking location");
193 if ((reg.RegionLocX > (x - 2)) && (reg.RegionLocX < (x + 2)))
194 {
195 if ((reg.RegionLocY > (y - 2)) && (reg.RegionLocY < (y + 2)))
196 {
197 neighbours.Add(reg);
198 }
199 }
200 }
201 }
202
203 return neighbours;
204 }
205
206 /// <summary>
207 /// Request information about a region.
208 /// </summary>
209 /// <param name="regionHandle"></param>
210 /// <returns>
211 /// null on a failure to contact or get a response from the grid server
212 /// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the
213 /// nature of the faiulre.
214 /// </returns>
215 public virtual RegionInfo RequestNeighbourInfo(UUID Region_UUID)
216 {
217 foreach (RegionInfo info in m_hyperlinkRegions)
218 {
219 if (info.RegionID == Region_UUID) return info;
220 }
221
222 // I don't trust region uuids to be unique...
223 //foreach (RegionInfo info in m_knownRegions.Values)
224 //{
225 // if (info.RegionID == Region_UUID) return info;
226 //}
227
228 return null;
229 }
230
231 /// <summary>
232 /// Request information about a region.
233 /// </summary>
234 /// <param name="regionHandle"></param>
235 /// <returns></returns>
236 public virtual RegionInfo RequestNeighbourInfo(ulong regionHandle)
237 {
238 //m_log.Debug(" >> RequestNeighbourInfo for " + regionHandle);
239 foreach (RegionInfo info in m_hyperlinkRegions)
240 {
241 //m_log.Debug(" .. " + info.RegionHandle);
242 if (info.RegionHandle == regionHandle) return info;
243 }
244
245 foreach (RegionInfo info in m_knownRegions.Values)
246 {
247 if (info.RegionHandle == regionHandle)
248 {
249 //m_log.Debug("XXX------ known region " + info.RegionHandle);
250 return info;
251 }
252 }
253
254 return null;
255 }
256
257 public virtual RegionInfo RequestNeighbourInfo(string name)
258 {
259 foreach (RegionInfo info in m_hyperlinkRegions)
260 {
261 //m_log.Debug(" .. " + info.RegionHandle);
262 if (info.RegionName == name) return info;
263 }
264
265 foreach (RegionInfo info in m_knownRegions.Values)
266 {
267 if (info.RegionName == name)
268 {
269 //m_log.Debug("XXX------ known region " + info.RegionHandle);
270 return info;
271 }
272 }
273
274 return null;
275 }
276
277 public virtual RegionInfo RequestNeighbourInfo(string hostName, uint port)
278 {
279 foreach (RegionInfo info in m_hyperlinkRegions)
280 {
281 //m_log.Debug(" .. " + info.RegionHandle);
282 if ((info.ExternalHostName == hostName) && (info.HttpPort == port))
283 return info;
284 }
285
286 foreach (RegionInfo info in m_knownRegions.Values)
287 {
288 if ((info.ExternalHostName == hostName) && (info.HttpPort == port))
289 {
290 //m_log.Debug("XXX------ known region " + info.RegionHandle);
291 return info;
292 }
293 }
294
295 return null;
296 }
297
298 public virtual RegionInfo RequestClosestRegion(string regionName)
299 {
300 foreach (RegionInfo info in m_hyperlinkRegions)
301 {
302 if (info.RegionName == regionName) return info;
303 }
304
305 return null;
306 }
307
308 /// <summary>
309 ///
310 /// </summary>
311 /// <param name="minX"></param>
312 /// <param name="minY"></param>
313 /// <param name="maxX"></param>
314 /// <param name="maxY"></param>
315 /// <returns></returns>
316 public virtual List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
317 {
318 List<MapBlockData> neighbours = new List<MapBlockData>();
319
320 foreach (RegionInfo regInfo in m_hyperlinkRegions)
321 {
322 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) &&
323 ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
324 {
325 MapBlockData map = new MapBlockData();
326 map.Name = regInfo.RegionName;
327 map.X = (ushort)regInfo.RegionLocX;
328 map.Y = (ushort)regInfo.RegionLocY;
329 map.WaterHeight = (byte)regInfo.RegionSettings.WaterHeight;
330 map.MapImageId = regInfo.RegionSettings.TerrainImageID;
331 // m_log.Debug("ImgID: " + map.MapImageId);
332 map.Agents = 1;
333 map.RegionFlags = 72458694;
334 map.Access = regInfo.AccessLevel;
335 neighbours.Add(map);
336 }
337 }
338
339 return neighbours;
340 }
341
342
343 protected virtual void GetMapImage(RegionInfo info)
344 {
345 try
346 {
347 string regionimage = "regionImage" + info.RegionID.ToString();
348 regionimage = regionimage.Replace("-", "");
349
350 WebClient c = new WebClient();
351 string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
352 //m_log.Debug("JPEG: " + uri);
353 c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
354 Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
355 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
356 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
357 AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString());
358 info.RegionSettings.TerrainImageID = ass.FullID;
359 ass.Type = (int)AssetType.Texture;
360 ass.Temporary = false;
361 ass.Local = true;
362 ass.Data = imageData;
363
364 m_sceneman.CurrentOrFirstScene.AssetService.Store(ass);
365
366 }
367 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
368 {
369 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
370 }
371 }
372
373 // A little ugly, since this code is exactly the same as OSG1's, and we're already
374 // calling that for when the region in in grid mode... (for the grid regions)
375 //
376 public virtual LandData RequestLandData (ulong regionHandle, uint x, uint y)
377 {
378 m_log.DebugFormat("[HGrid]: requests land data in {0}, at {1}, {2}",
379 regionHandle, x, y);
380
381 // Remote region
382
383 Hashtable hash = new Hashtable();
384 hash["region_handle"] = regionHandle.ToString();
385 hash["x"] = x.ToString();
386 hash["y"] = y.ToString();
387
388 IList paramList = new ArrayList();
389 paramList.Add(hash);
390 LandData landData = null;
391
392 try
393 {
394 RegionInfo info = RequestNeighbourInfo(regionHandle);
395 if (info != null) // just to be sure
396 {
397 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
398 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
399 XmlRpcResponse response = request.Send(uri, 10000);
400 if (response.IsFault)
401 {
402 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
403 }
404 else
405 {
406 hash = (Hashtable)response.Value;
407 try
408 {
409 landData = new LandData();
410 landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
411 landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
412 landData.Area = Convert.ToInt32(hash["Area"]);
413 landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]);
414 landData.Description = (string)hash["Description"];
415 landData.Flags = Convert.ToUInt32(hash["Flags"]);
416 landData.GlobalID = new UUID((string)hash["GlobalID"]);
417 landData.Name = (string)hash["Name"];
418 landData.OwnerID = new UUID((string)hash["OwnerID"]);
419 landData.SalePrice = Convert.ToInt32(hash["SalePrice"]);
420 landData.SnapshotID = new UUID((string)hash["SnapshotID"]);
421 landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
422 m_log.DebugFormat("[HGrid]: Got land data for parcel {0}", landData.Name);
423 }
424 catch (Exception e)
425 {
426 m_log.Error("[HGrid]: Got exception while parsing land-data:", e);
427 }
428 }
429 }
430 else m_log.WarnFormat("[HGrid]: Couldn't find region with handle {0}", regionHandle);
431 }
432 catch (Exception e)
433 {
434 m_log.ErrorFormat("[HGrid]: Couldn't contact region {0}: {1}", regionHandle, e);
435 }
436
437 return landData;
438 }
439
440 // Grid Request Processing
441 public virtual List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
442 {
443 List<RegionInfo> infos = new List<RegionInfo>();
444 foreach (RegionInfo info in m_hyperlinkRegions)
445 {
446 if (info.RegionName.ToLower().Contains(name))
447 {
448 infos.Add(info);
449 }
450 }
451 return infos;
452 }
453
454
455 private UUID LinkRegion(RegionInfo info)
456 {
457 UUID uuid = UUID.Zero;
458
459 Hashtable hash = new Hashtable();
460 hash["region_name"] = info.RegionName;
461
462 IList paramList = new ArrayList();
463 paramList.Add(hash);
464
465 XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
466 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
467 m_log.Debug("[HGrid]: Linking to " + uri);
468 XmlRpcResponse response = request.Send(uri, 10000);
469 if (response.IsFault)
470 {
471 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
472 }
473 else
474 {
475 hash = (Hashtable)response.Value;
476 //foreach (Object o in hash)
477 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
478 try
479 {
480 UUID.TryParse((string)hash["uuid"], out uuid);
481 info.RegionID = uuid;
482 if ((string)hash["handle"] != null)
483 {
484 info.regionSecret = (string)hash["handle"];
485 //m_log.Debug(">> HERE: " + info.regionSecret);
486 }
487 if (hash["region_image"] != null)
488 {
489 UUID img = UUID.Zero;
490 UUID.TryParse((string)hash["region_image"], out img);
491 info.RegionSettings.TerrainImageID = img;
492 }
493 if (hash["region_name"] != null)
494 {
495 info.RegionName = (string)hash["region_name"];
496 //m_log.Debug(">> " + info.RegionName);
497 }
498 if (hash["internal_port"] != null)
499 {
500 int port = Convert.ToInt32((string)hash["internal_port"]);
501 info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
502 //m_log.Debug(">> " + info.InternalEndPoint.ToString());
503 }
504 if (hash["remoting_port"] != null)
505 {
506 info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]);
507 //m_log.Debug(">> " + info.RemotingPort);
508 }
509
510 }
511 catch (Exception e)
512 {
513 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
514 }
515 }
516 return uuid;
517 }
518
519 /// <summary>
520 /// Someone wants to link to us
521 /// </summary>
522 /// <param name="request"></param>
523 /// <returns></returns>
524 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
525 {
526 Hashtable requestData = (Hashtable)request.Params[0];
527 //string host = (string)requestData["host"];
528 //string portstr = (string)requestData["port"];
529 string name = (string)requestData["region_name"];
530
531 m_log.DebugFormat("[HGrid]: Hyperlink request");
532
533
534 RegionInfo regInfo = null;
535 foreach (RegionInfo r in m_regionsOnInstance)
536 {
537 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
538 {
539 regInfo = r;
540 break;
541 }
542 }
543
544 if (regInfo == null)
545 regInfo = m_regionsOnInstance[0]; // Send out the first region
546
547 Hashtable hash = new Hashtable();
548 hash["uuid"] = regInfo.RegionID.ToString();
549 hash["handle"] = regInfo.RegionHandle.ToString();
550 //m_log.Debug(">> Here " + regInfo.RegionHandle);
551 hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
552 hash["region_name"] = regInfo.RegionName;
553 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
554 hash["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
555 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
556
557
558 XmlRpcResponse response = new XmlRpcResponse();
559 response.Value = hash;
560 return response;
561 }
562
563 public bool InformRegionOfUser(RegionInfo regInfo, AgentCircuitData agentData)
564 {
565 //ulong regionHandle = regInfo.RegionHandle;
566 try
567 {
568 //regionHandle = Convert.ToUInt64(regInfo.regionSecret);
569 m_log.Info("[HGrid]: InformRegionOfUser: Remote hyperlinked region " + regInfo.regionSecret);
570 }
571 catch
572 {
573 m_log.Info("[HGrid]: InformRegionOfUser: Local grid region " + regInfo.regionSecret);
574 }
575
576 string capsPath = agentData.CapsPath;
577 Hashtable loginParams = new Hashtable();
578 loginParams["session_id"] = agentData.SessionID.ToString();
579 loginParams["secure_session_id"] = agentData.SecureSessionID.ToString();
580
581 loginParams["firstname"] = agentData.firstname;
582 loginParams["lastname"] = agentData.lastname;
583
584 loginParams["agent_id"] = agentData.AgentID.ToString();
585 loginParams["circuit_code"] = agentData.circuitcode.ToString();
586 loginParams["startpos_x"] = agentData.startpos.X.ToString();
587 loginParams["startpos_y"] = agentData.startpos.Y.ToString();
588 loginParams["startpos_z"] = agentData.startpos.Z.ToString();
589 loginParams["caps_path"] = capsPath;
590
591 CachedUserInfo u = m_userProfileCache.GetUserDetails(agentData.AgentID);
592 if (u != null && u.UserProfile != null)
593 {
594 loginParams["region_uuid"] = u.UserProfile.HomeRegionID.ToString(); // This seems to be always Zero
595 //m_log.Debug(" --------- Home Region UUID -------");
596 //m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
597 //m_log.Debug(" --------- ---------------- -------");
598
599 string serverURI = "";
600 if (u.UserProfile is ForeignUserProfileData)
601 serverURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI);
602 loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI;
603
604 serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI);
605 loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI;
606
607 serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI);
608 loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI;
609
610 loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID;
611
612 RegionInfo rinfo = RequestNeighbourInfo(u.UserProfile.HomeRegion);
613 if (rinfo != null)
614 {
615 loginParams["internal_port"] = rinfo.InternalEndPoint.Port.ToString();
616 if (!IsLocalUser(u))
617 {
618 loginParams["regionhandle"] = rinfo.regionSecret; // user.CurrentAgent.Handle.ToString();
619 //m_log.Debug("XXX--- informregionofuser (foreign user) here handle: " + rinfo.regionSecret);
620
621 loginParams["home_address"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomeAddress;
622 loginParams["home_port"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomePort;
623 loginParams["home_remoting"] = ((ForeignUserProfileData)(u.UserProfile)).UserHomeRemotingPort;
624 }
625 else
626 {
627 //m_log.Debug("XXX--- informregionofuser (local user) here handle: " + rinfo.regionSecret);
628
629 //// local user about to jump out, let's process the name
630 // On second thoughts, let's not do this for the *user*; let's only do it for the *agent*
631 //loginParams["firstname"] = agentData.firstname + "." + agentData.lastname;
632 //loginParams["lastname"] = serversInfo.UserURL;
633
634 // local user, first time out. let's ask the grid about this user's home region
635 loginParams["regionhandle"] = u.UserProfile.HomeRegion.ToString(); // user.CurrentAgent.Handle.ToString();
636
637 loginParams["home_address"] = rinfo.ExternalHostName;
638 m_log.Debug(" --------- Home Address -------");
639 m_log.Debug(" >> " + loginParams["home_address"] + " <<");
640 m_log.Debug(" --------- ------------ -------");
641 loginParams["home_port"] = rinfo.HttpPort.ToString();
642 loginParams["home_remoting"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); ;
643 }
644 }
645 else
646 {
647 m_log.Warn("[HGrid]: User's home region info not found: " + u.UserProfile.HomeRegionX + ", " + u.UserProfile.HomeRegionY);
648 }
649 }
650
651 ArrayList SendParams = new ArrayList();
652 SendParams.Add(loginParams);
653
654 // Send
655 string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/";
656 //m_log.Debug("XXX uri: " + uri);
657 XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams);
658 XmlRpcResponse reply;
659 try
660 {
661 reply = request.Send(uri, 6000);
662 }
663 catch (Exception e)
664 {
665 m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message);
666 return false;
667 }
668
669 if (!reply.IsFault)
670 {
671 bool responseSuccess = true;
672 if (reply.Value != null)
673 {
674 Hashtable resp = (Hashtable)reply.Value;
675 if (resp.ContainsKey("success"))
676 {
677 if ((string)resp["success"] == "FALSE")
678 {
679 responseSuccess = false;
680 }
681 }
682 }
683 if (responseSuccess)
684 {
685 m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID);
686 return true;
687 }
688 else
689 {
690 m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients");
691 return false;
692 }
693 }
694 else
695 {
696 m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode);
697 return false;
698 }
699 }
700
701
702 /// <summary>
703 /// Received from other HGrid nodes when a user wants to teleport here. This call allows
704 /// the region to prepare for direct communication from the client. Sends back an empty
705 /// xmlrpc response on completion.
706 /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
707 /// registering the user in the local user cache.
708 /// </summary>
709 /// <param name="request"></param>
710 /// <returns></returns>
711 public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
712 {
713 Hashtable requestData = (Hashtable)request.Params[0];
714 ForeignUserProfileData userData = new ForeignUserProfileData();
715
716 userData.FirstName = (string)requestData["firstname"];
717 userData.SurName = (string)requestData["lastname"];
718 userData.ID = new UUID((string)requestData["agent_id"]);
719 userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
720 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
721 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
722
723 userData.UserServerURI = (string)requestData["userserver_id"];
724 userData.UserAssetURI = (string)requestData["assetserver_id"];
725 userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
726
727 UUID rootID = UUID.Zero;
728 UUID.TryParse((string)requestData["root_folder_id"], out rootID);
729 userData.RootInventoryFolderID = rootID;
730
731 UUID uuid = UUID.Zero;
732 UUID.TryParse((string)requestData["region_uuid"], out uuid);
733 userData.HomeRegionID = uuid; // not quite comfortable about this...
734 ulong userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
735 //userData.HomeRegion = userRegionHandle;
736 userData.UserHomeAddress = (string)requestData["home_address"];
737 userData.UserHomePort = (string)requestData["home_port"];
738 int userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
739 userData.UserHomeRemotingPort = (string)requestData["home_remoting"];
740
741
742 m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
743 userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
744 m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
745 "; home_port: " + userData.UserHomePort + "; remoting: " + userData.UserHomeRemotingPort);
746
747 XmlRpcResponse resp = new XmlRpcResponse();
748
749 // Let's check if someone is trying to get in with a stolen local identity.
750 // The need for this test is a consequence of not having truly global names :-/
751 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userData.ID);
752 if ((uinfo != null) && !(uinfo.UserProfile is ForeignUserProfileData))
753 {
754 m_log.WarnFormat("[HGrid]: Foreign user trying to get in with local identity. Access denied.");
755 Hashtable respdata = new Hashtable();
756 respdata["success"] = "FALSE";
757 respdata["reason"] = "Foreign user has the same ID as a local user.";
758 resp.Value = respdata;
759 return resp;
760 }
761
762 if (!RegionLoginsEnabled)
763 {
764 m_log.InfoFormat(
765 "[HGrid]: Denying access for user {0} {1} because region login is currently disabled",
766 userData.FirstName, userData.SurName);
767
768 Hashtable respdata = new Hashtable();
769 respdata["success"] = "FALSE";
770 respdata["reason"] = "region login currently disabled";
771 resp.Value = respdata;
772 }
773 else
774 {
775 // Finally, everything looks ok
776 //m_log.Debug("XXX---- EVERYTHING OK ---XXX");
777
778 // 1 - Preload the user data
779 m_userProfileCache.PreloadUserCache(userData);
780
781 if (m_knownRegions.ContainsKey(userData.ID))
782 {
783 // This was left here when the user departed
784 m_knownRegions.Remove(userData.ID);
785 }
786
787 // 2 - Load the region info into list of known regions
788 RegionInfo rinfo = new RegionInfo();
789 rinfo.RegionID = userData.HomeRegionID;
790 rinfo.ExternalHostName = userData.UserHomeAddress;
791 rinfo.HttpPort = Convert.ToUInt32(userData.UserHomePort);
792 rinfo.RemotingPort = Convert.ToUInt32(userData.UserHomeRemotingPort);
793 rinfo.RegionID = userData.HomeRegionID;
794 // X=0 on the map
795 rinfo.RegionLocX = 0;
796 rinfo.RegionLocY = (uint)(random.Next(0, Int32.MaxValue)); //(uint)m_knownRegions.Count;
797 rinfo.regionSecret = userRegionHandle.ToString();
798 //m_log.Debug("XXX--- Here: handle = " + rinfo.regionSecret);
799 try
800 {
801 rinfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
802 }
803 catch (Exception e)
804 {
805 m_log.Warn("[HGrid]: Exception while constructing internal endpoint: " + e);
806 }
807 rinfo.RemotingAddress = rinfo.ExternalEndPoint.Address.ToString(); //userData.UserHomeAddress;
808
809 if (!IsComingHome(userData))
810 {
811 // Change the user's home region here!!!
812 userData.HomeRegion = rinfo.RegionHandle;
813 }
814
815 if (!m_knownRegions.ContainsKey(userData.ID))
816 m_knownRegions.Add(userData.ID, rinfo);
817
818 // 3 - Send the reply
819 Hashtable respdata = new Hashtable();
820 respdata["success"] = "TRUE";
821 resp.Value = respdata;
822
823 DumpUserData(userData);
824 DumpRegionData(rinfo);
825
826 }
827
828 return resp;
829 }
830
831 public bool SendUserInformation(RegionInfo regInfo, AgentCircuitData agentData)
832 {
833 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID);
834
835 if ((IsLocalUser(uinfo) && IsHyperlinkRegion(regInfo.RegionHandle)) ||
836 (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
837 {
838 m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
839 if (!InformRegionOfUser(regInfo, agentData))
840 {
841 m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
842 return false;
843 }
844 }
845 //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
846 //{
847 // m_log.Info("[HGrid]: User seems to be going to foreign region.");
848 // if (!InformRegionOfUser(regInfo, agentData))
849 // {
850 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
851 // return false;
852 // }
853 //}
854 //else
855 // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
856
857 // May need to change agent's name
858 if (IsLocalUser(uinfo) && IsHyperlinkRegion(regInfo.RegionHandle))
859 {
860 agentData.firstname = agentData.firstname + "." + agentData.lastname;
861 agentData.lastname = "@" + serversInfo.UserURL.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
862 }
863
864 return true;
865 }
866
867
868 #region Methods triggered by calls from external instances
869
870 /// <summary>
871 ///
872 /// </summary>
873 /// <param name="regionHandle"></param>
874 /// <param name="agentData"></param>
875 /// <returns></returns>
876 public void AdjustUserInformation(AgentCircuitData agentData)
877 {
878 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID);
879 if ((uinfo != null) && (uinfo.UserProfile != null) &&
880 (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
881 {
882 //m_log.Debug("---------------> Local User!");
883 string[] parts = agentData.firstname.Split(new char[] { '.' });
884 if (parts.Length == 2)
885 {
886 agentData.firstname = parts[0];
887 agentData.lastname = parts[1];
888 }
889 }
890 //else
891 // m_log.Debug("---------------> Foreign User!");
892 }
893 #endregion
894
895
896 #region IHyperGrid interface
897
898 public virtual bool IsHyperlinkRegion(ulong ihandle)
899 {
900 if (GetHyperlinkRegion(ihandle) == null)
901 return false;
902 else
903 return true;
904 }
905
906 public virtual RegionInfo GetHyperlinkRegion(ulong ihandle)
907 {
908 foreach (RegionInfo info in m_hyperlinkRegions)
909 {
910 if (info.RegionHandle == ihandle)
911 return info;
912 }
913
914 foreach (RegionInfo info in m_knownRegions.Values)
915 {
916 if (info.RegionHandle == ihandle)
917 return info;
918 }
919
920 return null;
921 }
922
923 public virtual ulong FindRegionHandle(ulong ihandle)
924 {
925 long ohandle = -1;
926 List<RegionInfo> rlist = new List<RegionInfo>(m_hyperlinkRegions);
927 rlist.AddRange(m_knownRegions.Values);
928 foreach (RegionInfo info in rlist)
929 {
930 if (info.RegionHandle == ihandle)
931 {
932 try
933 {
934 ohandle = Convert.ToInt64(info.regionSecret);
935 m_log.Info("[HGrid] remote region " + ohandle);
936 }
937 catch
938 {
939 m_log.Error("[HGrid] Could not convert secret for " + ihandle + " (" + info.regionSecret + ")");
940 }
941 break;
942 }
943 }
944 return ohandle < 0 ? ihandle : (ulong)ohandle;
945 }
946 #endregion
947
948 #region Misc
949
950 protected bool IsComingHome(ForeignUserProfileData userData)
951 {
952 return (userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI);
953 }
954
955 protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo)
956 {
957 if (uinfo.UserProfile == null)
958 return false;
959
960 string userUserServerURI = String.Empty;
961 if (uinfo.UserProfile is ForeignUserProfileData)
962 {
963 userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
964 }
965
966 return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) &&
967 (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI));
968 }
969
970 protected bool IsLocalUser(CachedUserInfo uinfo)
971 {
972 if (uinfo == null)
973 return true;
974
975 if (uinfo.UserProfile is ForeignUserProfileData)
976 return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
977 else
978 return true;
979
980 }
981
982 protected bool IsLocalRegion(ulong handle)
983 {
984 foreach (RegionInfo reg in m_regionsOnInstance)
985 if (reg.RegionHandle == handle)
986 return true;
987 return false;
988 }
989
990 private void DumpUserData(ForeignUserProfileData userData)
991 {
992 m_log.Info(" ------------ User Data Dump ----------");
993 m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
994 m_log.Info(" >> HomeID: " + userData.HomeRegionID);
995 m_log.Info(" >> HomeHandle: " + userData.HomeRegion);
996 m_log.Info(" >> HomeX: " + userData.HomeRegionX);
997 m_log.Info(" >> HomeY: " + userData.HomeRegionY);
998 m_log.Info(" >> UserServer: " + userData.UserServerURI);
999 m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
1000 m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
1001 m_log.Info(" ------------ -------------- ----------");
1002 }
1003
1004 private void DumpRegionData(RegionInfo rinfo)
1005 {
1006 m_log.Info(" ------------ Region Data Dump ----------");
1007 m_log.Info(" >> handle: " + rinfo.RegionHandle);
1008 m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
1009 m_log.Info(" >> secret: " + rinfo.regionSecret);
1010 m_log.Info(" >> remoting address: " + rinfo.RemotingAddress);
1011 m_log.Info(" >> remoting port: " + rinfo.RemotingPort);
1012 m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
1013 m_log.Info(" >> http port: " + rinfo.HttpPort);
1014 m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
1015 m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
1016 m_log.Info(" ------------ -------------- ----------");
1017 }
1018
1019
1020 #endregion
1021
1022
1023 }
1024}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
deleted file mode 100644
index 5ce1e79..0000000
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
+++ /dev/null
@@ -1,159 +0,0 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Region.Communications.OGS1;
37using OpenSim.Region.Framework.Scenes;
38
39namespace OpenSim.Region.Communications.Hypergrid
40{
41 public class HGGridServicesGridMode : HGGridServices
42 {
43 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 /// <summary>
46 /// Encapsulate remote backend services for manipulation of grid regions
47 /// </summary>
48 private OGS1GridServices m_remoteBackend = null;
49
50 public OGS1GridServices RemoteBackend
51 {
52 get { return m_remoteBackend; }
53 }
54
55
56 public override string gdebugRegionName
57 {
58 get { return m_remoteBackend.gdebugRegionName; }
59 set { m_remoteBackend.gdebugRegionName = value; }
60 }
61
62 public override bool RegionLoginsEnabled
63 {
64 get { return m_remoteBackend.RegionLoginsEnabled; }
65 set { m_remoteBackend.RegionLoginsEnabled = value; }
66 }
67
68 public HGGridServicesGridMode(NetworkServersInfo servers_info,
69 SceneManager sman, UserProfileCacheService userv)
70 : base(servers_info, sman)
71 {
72 m_remoteBackend = new OGS1GridServices(servers_info);
73 m_userProfileCache = userv;
74 }
75
76 #region IGridServices interface
77
78 public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
79 {
80 if (!regionInfo.RegionID.Equals(UUID.Zero))
81 {
82 m_regionsOnInstance.Add(regionInfo);
83 return m_remoteBackend.RegisterRegion(regionInfo);
84 }
85 else
86 return base.RegisterRegion(regionInfo);
87 }
88
89 public override bool DeregisterRegion(RegionInfo regionInfo)
90 {
91 bool success = base.DeregisterRegion(regionInfo);
92 if (!success)
93 success = m_remoteBackend.DeregisterRegion(regionInfo);
94 return success;
95 }
96
97 public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
98 {
99 List<SimpleRegionInfo> neighbours = m_remoteBackend.RequestNeighbours(x, y);
100 //List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
101 //neighbours.AddRange(remotes);
102
103 return neighbours;
104 }
105
106 public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
107 {
108 RegionInfo info = m_remoteBackend.RequestNeighbourInfo(Region_UUID);
109 if (info == null)
110 info = base.RequestNeighbourInfo(Region_UUID);
111 return info;
112 }
113
114 public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
115 {
116 RegionInfo info = base.RequestNeighbourInfo(regionHandle);
117 if (info == null)
118 info = m_remoteBackend.RequestNeighbourInfo(regionHandle);
119 return info;
120 }
121
122 public override RegionInfo RequestClosestRegion(string regionName)
123 {
124 RegionInfo info = m_remoteBackend.RequestClosestRegion(regionName);
125 if (info == null)
126 info = base.RequestClosestRegion(regionName);
127 return info;
128 }
129
130 public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
131 {
132 List<MapBlockData> neighbours = m_remoteBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
133 List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
134 neighbours.AddRange(remotes);
135
136 return neighbours;
137 }
138
139 public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
140 {
141 LandData land = m_remoteBackend.RequestLandData(regionHandle, x, y);
142 if (land == null)
143 land = base.RequestLandData(regionHandle, x, y);
144 return land;
145 }
146
147 public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
148 {
149 List<RegionInfo> infos = m_remoteBackend.RequestNamedRegions(name, maxNumber);
150 List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
151 infos.AddRange(remotes);
152 return infos;
153 }
154
155 #endregion
156
157
158 }
159}
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
deleted file mode 100644
index 94cfc49..0000000
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
+++ /dev/null
@@ -1,259 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Net.Sockets;
33using System.Reflection;
34using System.Runtime.Remoting;
35using System.Runtime.Remoting.Channels;
36using System.Runtime.Remoting.Channels.Tcp;
37using System.Security.Authentication;
38using log4net;
39using Nwc.XmlRpc;
40using OpenMetaverse;
41using OpenSim.Framework;
42using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.HttpServer;
44using OpenSim.Region.Communications.Local;
45using OpenSim.Region.Communications.OGS1;
46using OpenSim.Region.Framework.Scenes;
47
48namespace OpenSim.Region.Communications.Hypergrid
49{
50 public class HGGridServicesStandalone : HGGridServices
51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 /// <summary>
55 /// Encapsulate local backend services for manipulation of local regions
56 /// </summary>
57 protected LocalBackEndServices m_localBackend = new LocalBackEndServices();
58
59 //private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>();
60
61 public LocalBackEndServices LocalBackend
62 {
63 get { return m_localBackend; }
64 }
65
66 public override string gdebugRegionName
67 {
68 get { return m_localBackend.gdebugRegionName; }
69 set { m_localBackend.gdebugRegionName = value; }
70 }
71
72 public override bool RegionLoginsEnabled
73 {
74 get { return m_localBackend.RegionLoginsEnabled; }
75 set { m_localBackend.RegionLoginsEnabled = value; }
76 }
77
78
79 public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, SceneManager sman)
80 : base(servers_info, sman)
81 {
82 //Respond to Grid Services requests
83 MainServer.Instance.AddXmlRPCHandler("logoff_user", LogOffUser);
84 MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply);
85 MainServer.Instance.AddXmlRPCHandler("land_data", LandData);
86
87 }
88
89 #region IGridServices interface
90
91 public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
92 {
93 if (!regionInfo.RegionID.Equals(UUID.Zero))
94 {
95 m_regionsOnInstance.Add(regionInfo);
96 return m_localBackend.RegisterRegion(regionInfo);
97 }
98 else
99 return base.RegisterRegion(regionInfo);
100
101 }
102
103 public override bool DeregisterRegion(RegionInfo regionInfo)
104 {
105 bool success = m_localBackend.DeregisterRegion(regionInfo);
106 if (!success)
107 success = base.DeregisterRegion(regionInfo);
108 return success;
109 }
110
111 public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
112 {
113 List<SimpleRegionInfo> neighbours = m_localBackend.RequestNeighbours(x, y);
114 //List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
115 //neighbours.AddRange(remotes);
116
117 return neighbours;
118 }
119
120 public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
121 {
122 RegionInfo info = m_localBackend.RequestNeighbourInfo(Region_UUID);
123 if (info == null)
124 info = base.RequestNeighbourInfo(Region_UUID);
125 return info;
126 }
127
128 public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
129 {
130 RegionInfo info = m_localBackend.RequestNeighbourInfo(regionHandle);
131 //m_log.Info("[HGrid] Request neighbor info, local backend returned " + info);
132 if (info == null)
133 info = base.RequestNeighbourInfo(regionHandle);
134 return info;
135 }
136
137 public override RegionInfo RequestClosestRegion(string regionName)
138 {
139 RegionInfo info = m_localBackend.RequestClosestRegion(regionName);
140 if (info == null)
141 info = base.RequestClosestRegion(regionName);
142 return info;
143 }
144
145 public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
146 {
147 //m_log.Info("[HGrid] Request map blocks " + minX + "-" + minY + "-" + maxX + "-" + maxY);
148 List<MapBlockData> neighbours = m_localBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
149 List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
150 neighbours.AddRange(remotes);
151
152 return neighbours;
153 }
154
155 public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
156 {
157 LandData land = m_localBackend.RequestLandData(regionHandle, x, y);
158 if (land == null)
159 land = base.RequestLandData(regionHandle, x, y);
160 return land;
161 }
162
163 public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
164 {
165 List<RegionInfo> infos = m_localBackend.RequestNamedRegions(name, maxNumber);
166 List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
167 infos.AddRange(remotes);
168 return infos;
169 }
170
171 #endregion
172
173 #region XML Request Handlers
174
175 /// <summary>
176 /// A ping / version check
177 /// </summary>
178 /// <param name="request"></param>
179 /// <returns></returns>
180 public virtual XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient)
181 {
182 XmlRpcResponse response = new XmlRpcResponse();
183
184 Hashtable respData = new Hashtable();
185 respData["online"] = "true";
186
187 m_localBackend.PingCheckReply(respData);
188
189 response.Value = respData;
190
191 return response;
192 }
193
194
195 // Grid Request Processing
196 /// <summary>
197 /// Ooops, our Agent must be dead if we're getting this request!
198 /// </summary>
199 /// <param name="request"></param>
200 /// <returns></returns>
201 public XmlRpcResponse LogOffUser(XmlRpcRequest request, IPEndPoint remoteClient)
202 {
203 m_log.Debug("[HGrid]: LogOff User Called");
204
205 Hashtable requestData = (Hashtable)request.Params[0];
206 string message = (string)requestData["message"];
207 UUID agentID = UUID.Zero;
208 UUID RegionSecret = UUID.Zero;
209 UUID.TryParse((string)requestData["agent_id"], out agentID);
210 UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
211
212 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
213
214 m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret, message);
215
216 return new XmlRpcResponse();
217 }
218
219 /// <summary>
220 /// Someone asked us about parcel-information
221 /// </summary>
222 /// <param name="request"></param>
223 /// <returns></returns>
224 public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient)
225 {
226 Hashtable requestData = (Hashtable)request.Params[0];
227 ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
228 uint x = Convert.ToUInt32(requestData["x"]);
229 uint y = Convert.ToUInt32(requestData["y"]);
230 m_log.DebugFormat("[HGrid]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle);
231
232 LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
233 Hashtable hash = new Hashtable();
234 if (landData != null)
235 {
236 // for now, only push out the data we need for answering a ParcelInfoReqeust
237 hash["AABBMax"] = landData.AABBMax.ToString();
238 hash["AABBMin"] = landData.AABBMin.ToString();
239 hash["Area"] = landData.Area.ToString();
240 hash["AuctionID"] = landData.AuctionID.ToString();
241 hash["Description"] = landData.Description;
242 hash["Flags"] = landData.Flags.ToString();
243 hash["GlobalID"] = landData.GlobalID.ToString();
244 hash["Name"] = landData.Name;
245 hash["OwnerID"] = landData.OwnerID.ToString();
246 hash["SalePrice"] = landData.SalePrice.ToString();
247 hash["SnapshotID"] = landData.SnapshotID.ToString();
248 hash["UserLocation"] = landData.UserLocation.ToString();
249 }
250
251 XmlRpcResponse response = new XmlRpcResponse();
252 response.Value = hash;
253 return response;
254 }
255
256 #endregion
257
258 }
259}
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
index a658416..99bcea3 100644
--- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -53,8 +53,6 @@ namespace OpenSim.Region.Communications.Local
53 m_avatarService = lus; 53 m_avatarService = lus;
54 m_messageService = lus; 54 m_messageService = lus;
55 55
56 m_gridService = new LocalBackEndServices();
57
58 //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService); 56 //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService);
59 } 57 }
60 } 58 }
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
deleted file mode 100644
index 0ab9374..0000000
--- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
+++ /dev/null
@@ -1,410 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36
37namespace OpenSim.Region.Communications.Local
38{
39 public class LocalBackEndServices : IGridServices
40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 protected Dictionary<ulong, RegionInfo> m_regions = new Dictionary<ulong, RegionInfo>();
44
45 protected Dictionary<ulong, RegionCommsListener> m_regionListeners =
46 new Dictionary<ulong, RegionCommsListener>();
47
48 // private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>();
49
50 private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
51
52 public string _gdebugRegionName = String.Empty;
53
54 public bool RegionLoginsEnabled
55 {
56 get { return m_regionLoginsEnabled; }
57 set { m_regionLoginsEnabled = value; }
58 }
59 private bool m_regionLoginsEnabled;
60
61 public bool CheckRegion(string address, uint port)
62 {
63 return true;
64 }
65
66 public string gdebugRegionName
67 {
68 get { return _gdebugRegionName; }
69 set { _gdebugRegionName = value; }
70 }
71
72 public string _rdebugRegionName = String.Empty;
73
74 public string rdebugRegionName
75 {
76 get { return _rdebugRegionName; }
77 set { _rdebugRegionName = value; }
78 }
79
80 /// <summary>
81 /// Register a region method with the BackEnd Services.
82 /// </summary>
83 /// <param name="regionInfo"></param>
84 /// <returns></returns>
85 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
86 {
87 //m_log.Debug("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
88 if (!m_regions.ContainsKey(regionInfo.RegionHandle))
89 {
90 //m_log.Debug("CommsManager - Adding Region " + regionInfo.RegionHandle);
91 m_regions.Add(regionInfo.RegionHandle, regionInfo);
92
93 RegionCommsListener regionHost = new RegionCommsListener();
94 if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
95 {
96 m_log.Error("[INTERREGION STANDALONE]: " +
97 "Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. " +
98 "In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up.");
99 m_regionListeners.Remove(regionInfo.RegionHandle);
100 }
101 m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
102
103 return regionHost;
104 }
105 else
106 {
107 // Already in our list, so the region went dead and restarted.
108 // don't replace the old regioninfo.. this might be a locking issue.. however we need to
109 // remove it and let it add normally below or we get extremely strange and intermittant
110 // connectivity errors.
111 // Don't change this line below to 'm_regions[regionInfo.RegionHandle] = regionInfo' unless you
112 // *REALLY* know what you are doing here.
113 m_regions[regionInfo.RegionHandle] = regionInfo;
114
115 m_log.Warn("[INTERREGION STANDALONE]: Region registered twice. Region went down and came back up.");
116
117 RegionCommsListener regionHost = new RegionCommsListener();
118 if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
119 {
120 m_regionListeners.Remove(regionInfo.RegionHandle);
121 }
122 m_regionListeners.Add(regionInfo.RegionHandle, regionHost);
123
124 return regionHost;
125 }
126 }
127
128 public bool DeregisterRegion(RegionInfo regionInfo)
129 {
130 if (m_regions.ContainsKey(regionInfo.RegionHandle))
131 {
132 m_regions.Remove(regionInfo.RegionHandle);
133 if (m_regionListeners.ContainsKey(regionInfo.RegionHandle))
134 {
135 m_regionListeners.Remove(regionInfo.RegionHandle);
136 }
137 return true;
138 }
139 return false;
140 }
141
142 /// <summary>
143 /// </summary>
144 /// <param name="regionInfo"></param>
145 /// <returns></returns>
146 public List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
147 {
148 // m_log.Debug("Finding Neighbours to " + regionInfo.RegionHandle);
149 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
150
151 foreach (RegionInfo reg in m_regions.Values)
152 {
153 // m_log.Debug("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
154 if (reg.RegionLocX != x || reg.RegionLocY != y)
155 {
156 //m_log.Debug("CommsManager- RequestNeighbours() - found a different region in list, checking location");
157 if ((reg.RegionLocX > (x - 2)) && (reg.RegionLocX < (x + 2)))
158 {
159 if ((reg.RegionLocY > (y - 2)) && (reg.RegionLocY < (y + 2)))
160 {
161 neighbours.Add(reg);
162 }
163 }
164 }
165 }
166 return neighbours;
167 }
168
169 /// <summary>
170 /// Get information about a neighbouring region
171 /// </summary>
172 /// <param name="regionHandle"></param>
173 /// <returns></returns>
174 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
175 {
176 if (m_regions.ContainsKey(regionHandle))
177 {
178 return m_regions[regionHandle];
179 }
180
181 return null;
182 }
183
184 /// <summary>
185 /// Get information about a neighbouring region
186 /// </summary>
187 /// <param name="regionHandle"></param>
188 /// <returns></returns>
189 public RegionInfo RequestNeighbourInfo(UUID regionID)
190 {
191 // TODO add a dictionary for faster lookup
192 foreach (RegionInfo info in m_regions.Values)
193 {
194 if (info.RegionID == regionID)
195 return info;
196 }
197
198 return null;
199 }
200
201 /// <summary>
202 /// Get information about a neighbouring region
203 /// </summary>
204 /// <param name="regionHandle"></param>
205 /// <returns></returns>
206 public RegionInfo RequestNeighbourInfo(string name)
207 {
208 foreach (RegionInfo info in m_regions.Values)
209 {
210 if (info.RegionName == name)
211 return info;
212 }
213
214 return null;
215 }
216
217 /// <summary>
218 /// Get information about a neighbouring region
219 /// </summary>
220 /// <param name="regionHandle"></param>
221 /// <returns></returns>
222 public RegionInfo RequestNeighbourInfo(string host, uint port)
223 {
224 foreach (RegionInfo info in m_regions.Values)
225 {
226 if ((info.ExternalHostName == host) && (info.HttpPort == port))
227 return info;
228 }
229
230 return null;
231 }
232
233 /// <summary>
234 /// Get information about the closet region given a region name.
235 /// </summary>
236 /// <param name="regionName"></param>
237 /// <returns></returns>
238 public RegionInfo RequestClosestRegion(string regionName)
239 {
240 foreach (RegionInfo regInfo in m_regions.Values)
241 {
242 if (regInfo.RegionName == regionName)
243 return regInfo;
244 }
245 return null;
246 }
247
248 /// <summary>
249 ///
250 /// </summary>
251 /// <param name="minX"></param>
252 /// <param name="minY"></param>
253 /// <param name="maxX"></param>
254 /// <param name="maxY"></param>
255 /// <returns></returns>
256 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
257 {
258 List<MapBlockData> mapBlocks = new List<MapBlockData>();
259 foreach (RegionInfo regInfo in m_regions.Values)
260 {
261 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) &&
262 ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
263 {
264 MapBlockData map = new MapBlockData();
265 map.Name = regInfo.RegionName;
266 map.X = (ushort) regInfo.RegionLocX;
267 map.Y = (ushort) regInfo.RegionLocY;
268 map.WaterHeight = (byte) regInfo.RegionSettings.WaterHeight;
269 map.MapImageId = regInfo.RegionSettings.TerrainImageID;
270 map.Agents = 1;
271 map.RegionFlags = 72458694;
272 map.Access = regInfo.AccessLevel;
273 mapBlocks.Add(map);
274 }
275 }
276 return mapBlocks;
277 }
278
279 // This function is only here to keep this class in line with the Grid Interface.
280 // It never gets called.
281 public virtual Dictionary<string, string> GetGridSettings()
282 {
283 Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
284 lock (m_queuedGridSettings)
285 {
286 returnGridSettings = m_queuedGridSettings;
287 m_queuedGridSettings.Clear();
288 }
289
290 return returnGridSettings;
291 }
292
293 public virtual void SetForcefulBanlistsDisallowed()
294 {
295 m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
296 }
297
298
299 /// <summary>
300 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
301 /// </summary>
302 /// <param name="regionHandle"></param>
303 /// <param name="loginData"></param>
304 /// <returns></returns>
305 public void AddNewSession(ulong regionHandle, Login loginData)
306 {
307 AgentCircuitData agent = new AgentCircuitData();
308 agent.AgentID = loginData.Agent;
309 agent.firstname = loginData.First;
310 agent.lastname = loginData.Last;
311 agent.SessionID = loginData.Session;
312 agent.SecureSessionID = loginData.SecureSession;
313 agent.circuitcode = loginData.CircuitCode;
314 agent.BaseFolder = loginData.BaseFolder;
315 agent.InventoryFolder = loginData.InventoryFolder;
316 agent.startpos = loginData.StartPos;
317 agent.CapsPath = loginData.CapsPath;
318 if (loginData.Appearance != null)
319 agent.Appearance = loginData.Appearance;
320 else
321 {
322 m_log.WarnFormat("[INTER]: Appearance not found for {0} {1}. Creating default.", agent.firstname, agent.lastname);
323 agent.Appearance = new AvatarAppearance(agent.AgentID);
324 }
325
326 TriggerExpectUser(regionHandle, agent);
327 }
328
329 public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
330 {
331 //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: Other region is sending child agent our way: " + agent.firstname + " " + agent.lastname);
332
333 if (m_regionListeners.ContainsKey(regionHandle))
334 {
335 //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
336
337 m_regionListeners[regionHandle].TriggerExpectUser(agent);
338 }
339 }
340
341 public void TriggerLogOffUser(ulong regionHandle, UUID agentID, UUID RegionSecret, string message)
342 {
343 if (m_regionListeners.ContainsKey(regionHandle))
344 {
345 //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
346
347 m_regionListeners[regionHandle].TriggerLogOffUser(agentID, RegionSecret, message);
348 }
349 }
350
351 public void PingCheckReply(Hashtable respData)
352 {
353 foreach (ulong region in m_regions.Keys)
354 {
355 Hashtable regData = new Hashtable();
356 RegionInfo reg = m_regions[region];
357 regData["status"] = "active";
358 regData["handle"] = region.ToString();
359
360 respData[reg.RegionID.ToString()] = regData;
361 }
362 }
363
364
365 public LandData RequestLandData (ulong regionHandle, uint x, uint y)
366 {
367 m_log.DebugFormat("[INTERREGION STANDALONE] requests land data in {0}, at {1}, {2}",
368 regionHandle, x, y);
369
370 if (m_regionListeners.ContainsKey(regionHandle))
371 {
372 LandData land = m_regionListeners[regionHandle].TriggerGetLandData(x, y);
373 return land;
374 }
375
376 m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally.");
377 return null;
378 }
379
380 public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
381 {
382 List<RegionInfo> lowercase_regions = new List<RegionInfo>();
383 List<RegionInfo> regions = new List<RegionInfo>();
384 foreach (RegionInfo info in m_regions.Values)
385 {
386 // Prioritizes exact match
387 if (info.RegionName.StartsWith(name))
388 {
389 regions.Add(info);
390 if (regions.Count >= maxNumber) break;
391 }
392 // But still saves lower case matches
393 else if (info.RegionName.ToLower().StartsWith(name))
394 {
395 if (lowercase_regions.Count < maxNumber)
396 {
397 lowercase_regions.Add(info);
398 }
399 }
400 }
401
402 // If no exact matches found, return lowercase matches (libOMV compatiblity)
403 if (regions.Count == 0 && lowercase_regions.Count != 0)
404 {
405 return lowercase_regions;
406 }
407 return regions;
408 }
409 }
410}
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
index 8b5779f..c2b8f26 100644
--- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
+++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs
@@ -39,8 +39,6 @@ namespace OpenSim.Region.Communications.OGS1
39 LibraryRootFolder libraryRootFolder) 39 LibraryRootFolder libraryRootFolder)
40 : base(serversInfo, libraryRootFolder) 40 : base(serversInfo, libraryRootFolder)
41 { 41 {
42 OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo);
43 m_gridService = gridInterComms;
44 42
45 // This plugin arrangement could eventually be configurable rather than hardcoded here. 43 // This plugin arrangement could eventually be configurable rather than hardcoded here.
46 OGS1UserServices userServices = new OGS1UserServices(this); 44 OGS1UserServices userServices = new OGS1UserServices(this);
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
deleted file mode 100644
index 47c7fe4..0000000
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ /dev/null
@@ -1,937 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Net.Sockets;
33using System.Reflection;
34using log4net;
35using Nwc.XmlRpc;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Communications.Local;
41
42namespace OpenSim.Region.Communications.OGS1
43{
44 public class OGS1GridServices : IGridServices
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private bool m_useRemoteRegionCache = true;
49 /// <summary>
50 /// Encapsulate local backend services for manipulation of local regions
51 /// </summary>
52 private LocalBackEndServices m_localBackend = new LocalBackEndServices();
53
54 private Dictionary<ulong, RegionInfo> m_remoteRegionInfoCache = new Dictionary<ulong, RegionInfo>();
55 // private List<SimpleRegionInfo> m_knownRegions = new List<SimpleRegionInfo>();
56 private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>();
57 private Dictionary<string, string> m_queuedGridSettings = new Dictionary<string, string>();
58 private List<RegionInfo> m_regionsOnInstance = new List<RegionInfo>();
59
60 public BaseHttpServer httpListener;
61 public NetworkServersInfo serversInfo;
62
63 public string gdebugRegionName
64 {
65 get { return m_localBackend.gdebugRegionName; }
66 set { m_localBackend.gdebugRegionName = value; }
67 }
68
69 public string rdebugRegionName
70 {
71 get { return _rdebugRegionName; }
72 set { _rdebugRegionName = value; }
73 }
74 private string _rdebugRegionName = String.Empty;
75
76 public bool RegionLoginsEnabled
77 {
78 get { return m_localBackend.RegionLoginsEnabled; }
79 set { m_localBackend.RegionLoginsEnabled = value; }
80 }
81
82 /// <summary>
83 /// Contructor. Adds "expect_user" and "check" xmlrpc method handlers
84 /// </summary>
85 /// <param name="servers_info"></param>
86 /// <param name="httpServe"></param>
87 public OGS1GridServices(NetworkServersInfo servers_info)
88 {
89 serversInfo = servers_info;
90
91 //Respond to Grid Services requests
92 MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply);
93 }
94
95 // see IGridServices
96 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
97 {
98 if (m_regionsOnInstance.Contains(regionInfo))
99 {
100 m_log.Error("[OGS1 GRID SERVICES]: Foobar! Caller is confused, region already registered " + regionInfo.RegionName);
101 Exception e = new Exception(String.Format("Unable to register region"));
102
103 throw e;
104 }
105
106 m_log.InfoFormat(
107 "[OGS1 GRID SERVICES]: Registering region {0} with grid at {1}",
108 regionInfo.RegionName, serversInfo.GridURL);
109
110 m_regionsOnInstance.Add(regionInfo);
111
112 Hashtable GridParams = new Hashtable();
113 // Login / Authentication
114
115 GridParams["authkey"] = serversInfo.GridSendKey;
116 GridParams["recvkey"] = serversInfo.GridRecvKey;
117 GridParams["UUID"] = regionInfo.RegionID.ToString();
118 GridParams["sim_ip"] = regionInfo.ExternalHostName;
119 GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
120 GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
121 GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
122 GridParams["sim_name"] = regionInfo.RegionName;
123 GridParams["http_port"] = serversInfo.HttpListenerPort.ToString();
124 GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
125 GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString();
126 GridParams["originUUID"] = regionInfo.originRegionID.ToString();
127 GridParams["server_uri"] = regionInfo.ServerURI;
128 GridParams["region_secret"] = regionInfo.regionSecret;
129 GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString();
130
131 if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero)
132 GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString();
133 else
134 GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString();
135
136 GridParams["maturity"] = regionInfo.RegionSettings.Maturity.ToString();
137
138 // Package into an XMLRPC Request
139 ArrayList SendParams = new ArrayList();
140 SendParams.Add(GridParams);
141
142 // Send Request
143 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
144 XmlRpcResponse GridResp;
145
146 try
147 {
148 // The timeout should always be significantly larger than the timeout for the grid server to request
149 // the initial status of the region before confirming registration.
150 GridResp = GridReq.Send(serversInfo.GridURL, 9999999);
151 }
152 catch (Exception e)
153 {
154 Exception e2
155 = new Exception(
156 String.Format(
157 "Unable to register region with grid at {0}. Grid service not running?",
158 serversInfo.GridURL),
159 e);
160
161 throw e2;
162 }
163
164 Hashtable GridRespData = (Hashtable)GridResp.Value;
165 // Hashtable griddatahash = GridRespData;
166
167 // Process Response
168 if (GridRespData.ContainsKey("error"))
169 {
170 string errorstring = (string) GridRespData["error"];
171
172 Exception e = new Exception(
173 String.Format("Unable to connect to grid at {0}: {1}", serversInfo.GridURL, errorstring));
174
175 throw e;
176 }
177 else
178 {
179 // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY);
180 if (GridRespData.ContainsKey("allow_forceful_banlines"))
181 {
182 if ((string) GridRespData["allow_forceful_banlines"] != "TRUE")
183 {
184 //m_localBackend.SetForcefulBanlistsDisallowed(regionInfo.RegionHandle);
185 if (!m_queuedGridSettings.ContainsKey("allow_forceful_banlines"))
186 m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE");
187 }
188 }
189
190 m_log.InfoFormat(
191 "[OGS1 GRID SERVICES]: Region {0} successfully registered with grid at {1}",
192 regionInfo.RegionName, serversInfo.GridURL);
193 }
194
195 return m_localBackend.RegisterRegion(regionInfo);
196 }
197
198 // see IGridServices
199 public bool DeregisterRegion(RegionInfo regionInfo)
200 {
201 Hashtable GridParams = new Hashtable();
202
203 GridParams["UUID"] = regionInfo.RegionID.ToString();
204
205 // Package into an XMLRPC Request
206 ArrayList SendParams = new ArrayList();
207 SendParams.Add(GridParams);
208
209 // Send Request
210 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams);
211 XmlRpcResponse GridResp = null;
212
213 try
214 {
215 GridResp = GridReq.Send(serversInfo.GridURL, 10000);
216 }
217 catch (Exception e)
218 {
219 Exception e2
220 = new Exception(
221 String.Format(
222 "Unable to deregister region with grid at {0}. Grid service not running?",
223 serversInfo.GridURL),
224 e);
225
226 throw e2;
227 }
228
229 Hashtable GridRespData = (Hashtable) GridResp.Value;
230
231 // Hashtable griddatahash = GridRespData;
232
233 // Process Response
234 if (GridRespData != null && GridRespData.ContainsKey("error"))
235 {
236 string errorstring = (string)GridRespData["error"];
237 m_log.Error("Unable to connect to grid: " + errorstring);
238 return false;
239 }
240
241 return m_localBackend.DeregisterRegion(regionInfo);
242 }
243
244 public virtual Dictionary<string, string> GetGridSettings()
245 {
246 Dictionary<string, string> returnGridSettings = new Dictionary<string, string>();
247 lock (m_queuedGridSettings)
248 {
249 foreach (string Dictkey in m_queuedGridSettings.Keys)
250 {
251 returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]);
252 }
253
254 m_queuedGridSettings.Clear();
255 }
256
257 return returnGridSettings;
258 }
259
260 // see IGridServices
261 public List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
262 {
263 Hashtable respData = MapBlockQuery((int) x - 1, (int) y - 1, (int) x + 1, (int) y + 1);
264
265 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
266
267 foreach (ArrayList neighboursList in respData.Values)
268 {
269 foreach (Hashtable neighbourData in neighboursList)
270 {
271 uint regX = Convert.ToUInt32(neighbourData["x"]);
272 uint regY = Convert.ToUInt32(neighbourData["y"]);
273 if ((x != regX) || (y != regY))
274 {
275 string simIp = (string) neighbourData["sim_ip"];
276
277 uint port = Convert.ToUInt32(neighbourData["sim_port"]);
278 // string externalUri = (string) neighbourData["sim_uri"];
279
280 // string externalIpStr = String.Empty;
281 try
282 {
283 // externalIpStr = Util.GetHostFromDNS(simIp).ToString();
284 Util.GetHostFromDNS(simIp).ToString();
285 }
286 catch (SocketException e)
287 {
288 m_log.WarnFormat(
289 "[OGS1 GRID SERVICES]: RequestNeighbours(): Lookup of neighbour {0} failed! Not including in neighbours list. {1}",
290 simIp, e);
291
292 continue;
293 }
294
295 SimpleRegionInfo sri = new SimpleRegionInfo(regX, regY, simIp, port);
296
297 sri.RemotingPort = Convert.ToUInt32(neighbourData["remoting_port"]);
298
299 if (neighbourData.ContainsKey("http_port"))
300 {
301 sri.HttpPort = Convert.ToUInt32(neighbourData["http_port"]);
302 }
303 else
304 {
305 m_log.Error("[OGS1 GRID SERVICES]: Couldn't find httpPort, using default 9000; please upgrade your grid-server to r7621 or later");
306 sri.HttpPort = 9000; // that's the default and will probably be wrong
307 }
308
309 sri.RegionID = new UUID((string) neighbourData["uuid"]);
310
311 neighbours.Add(sri);
312 }
313 }
314 }
315
316 return neighbours;
317 }
318
319 /// <summary>
320 /// Request information about a region.
321 /// </summary>
322 /// <param name="regionHandle"></param>
323 /// <returns>
324 /// null on a failure to contact or get a response from the grid server
325 /// FIXME: Might be nicer to return a proper exception here since we could inform the client more about the
326 /// nature of the faiulre.
327 /// </returns>
328 public RegionInfo RequestNeighbourInfo(UUID Region_UUID)
329 {
330 // don't ask the gridserver about regions on this instance...
331 foreach (RegionInfo info in m_regionsOnInstance)
332 {
333 if (info.RegionID == Region_UUID) return info;
334 }
335
336 // didn't find it so far, we have to go the long way
337 RegionInfo regionInfo;
338 Hashtable requestData = new Hashtable();
339 requestData["region_UUID"] = Region_UUID.ToString();
340 requestData["authkey"] = serversInfo.GridSendKey;
341 ArrayList SendParams = new ArrayList();
342 SendParams.Add(requestData);
343 XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams);
344 XmlRpcResponse gridResp = null;
345
346 try
347 {
348 gridResp = gridReq.Send(serversInfo.GridURL, 3000);
349 }
350 catch (Exception e)
351 {
352 m_log.ErrorFormat(
353 "[OGS1 GRID SERVICES]: Communication with the grid server at {0} failed, {1}",
354 serversInfo.GridURL, e);
355
356 return null;
357 }
358
359 Hashtable responseData = (Hashtable)gridResp.Value;
360
361 if (responseData.ContainsKey("error"))
362 {
363 m_log.WarnFormat("[OGS1 GRID SERVICES]: Error received from grid server: {0}", responseData["error"]);
364 return null;
365 }
366
367 regionInfo = buildRegionInfo(responseData, String.Empty);
368 if ((m_useRemoteRegionCache) && (requestData.ContainsKey("regionHandle")))
369 {
370 m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo);
371 }
372
373 return regionInfo;
374 }
375
376 /// <summary>
377 /// Request information about a region.
378 /// </summary>
379 /// <param name="regionHandle"></param>
380 /// <returns></returns>
381 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
382 {
383 RegionInfo regionInfo = m_localBackend.RequestNeighbourInfo(regionHandle);
384
385 if (regionInfo != null)
386 {
387 return regionInfo;
388 }
389
390 if ((!m_useRemoteRegionCache) || (!m_remoteRegionInfoCache.TryGetValue(regionHandle, out regionInfo)))
391 {
392 try
393 {
394 Hashtable requestData = new Hashtable();
395 requestData["region_handle"] = regionHandle.ToString();
396 requestData["authkey"] = serversInfo.GridSendKey;
397 ArrayList SendParams = new ArrayList();
398 SendParams.Add(requestData);
399 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
400 XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
401
402 Hashtable responseData = (Hashtable) GridResp.Value;
403
404 if (responseData.ContainsKey("error"))
405 {
406 m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server: " + responseData["error"]);
407 return null;
408 }
409
410 uint regX = Convert.ToUInt32((string) responseData["region_locx"]);
411 uint regY = Convert.ToUInt32((string) responseData["region_locy"]);
412 string externalHostName = (string) responseData["sim_ip"];
413 uint simPort = Convert.ToUInt32(responseData["sim_port"]);
414 string regionName = (string)responseData["region_name"];
415 UUID regionID = new UUID((string)responseData["region_UUID"]);
416 uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
417
418 uint httpPort = 9000;
419 if (responseData.ContainsKey("http_port"))
420 {
421 httpPort = Convert.ToUInt32((string)responseData["http_port"]);
422 }
423
424 // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info?
425
426 string simURI = "http://" + externalHostName + ":" + simPort;
427
428 // string externalUri = (string) responseData["sim_uri"];
429
430 //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
431 regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI);
432
433 if (m_useRemoteRegionCache)
434 {
435 lock (m_remoteRegionInfoCache)
436 {
437 if (!m_remoteRegionInfoCache.ContainsKey(regionHandle))
438 {
439 m_remoteRegionInfoCache.Add(regionHandle, regionInfo);
440 }
441 }
442 }
443 }
444 catch (Exception e)
445 {
446 m_log.Error("[OGS1 GRID SERVICES]: " +
447 "Region lookup failed for: " + regionHandle.ToString() +
448 " - Is the GridServer down?" + e.ToString());
449 return null;
450 }
451 }
452
453 return regionInfo;
454 }
455
456 /// <summary>
457 /// Get information about a neighbouring region
458 /// </summary>
459 /// <param name="regionHandle"></param>
460 /// <returns></returns>
461 public RegionInfo RequestNeighbourInfo(string name)
462 {
463 // Not implemented yet
464 return null;
465 }
466
467 /// <summary>
468 /// Get information about a neighbouring region
469 /// </summary>
470 /// <param name="regionHandle"></param>
471 /// <returns></returns>
472 public RegionInfo RequestNeighbourInfo(string host, uint port)
473 {
474 // Not implemented yet
475 return null;
476 }
477
478 public RegionInfo RequestClosestRegion(string regionName)
479 {
480 if (m_useRemoteRegionCache)
481 {
482 foreach (RegionInfo ri in m_remoteRegionInfoCache.Values)
483 {
484 if (ri.RegionName == regionName)
485 return ri;
486 }
487 }
488
489 RegionInfo regionInfo = null;
490 try
491 {
492 Hashtable requestData = new Hashtable();
493 requestData["region_name_search"] = regionName;
494 requestData["authkey"] = serversInfo.GridSendKey;
495 ArrayList SendParams = new ArrayList();
496 SendParams.Add(requestData);
497 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
498 XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000);
499
500 Hashtable responseData = (Hashtable) GridResp.Value;
501
502 if (responseData.ContainsKey("error"))
503 {
504 m_log.ErrorFormat("[OGS1 GRID SERVICES]: Error received from grid server: ", responseData["error"]);
505 return null;
506 }
507
508 regionInfo = buildRegionInfo(responseData, "");
509
510 if ((m_useRemoteRegionCache) && (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle)))
511 m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo);
512 }
513 catch
514 {
515 m_log.Error("[OGS1 GRID SERVICES]: " +
516 "Region lookup failed for: " + regionName +
517 " - Is the GridServer down?");
518 }
519
520 return regionInfo;
521 }
522
523 /// <summary>
524 ///
525 /// </summary>
526 /// <param name="minX"></param>
527 /// <param name="minY"></param>
528 /// <param name="maxX"></param>
529 /// <param name="maxY"></param>
530 /// <returns></returns>
531 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
532 {
533 int temp = 0;
534
535 if (minX > maxX)
536 {
537 temp = minX;
538 minX = maxX;
539 maxX = temp;
540 }
541 if (minY > maxY)
542 {
543 temp = minY;
544 minY = maxY;
545 maxY = temp;
546 }
547
548 Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY);
549
550 List<MapBlockData> neighbours = new List<MapBlockData>();
551
552 foreach (ArrayList a in respData.Values)
553 {
554 foreach (Hashtable n in a)
555 {
556 MapBlockData neighbour = new MapBlockData();
557
558 neighbour.X = Convert.ToUInt16(n["x"]);
559 neighbour.Y = Convert.ToUInt16(n["y"]);
560
561 neighbour.Name = (string) n["name"];
562 neighbour.Access = Convert.ToByte(n["access"]);
563 neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]);
564 neighbour.WaterHeight = Convert.ToByte(n["water-height"]);
565 neighbour.MapImageId = new UUID((string) n["map-image-id"]);
566
567 neighbours.Add(neighbour);
568 }
569 }
570
571 return neighbours;
572 }
573
574 /// <summary>
575 /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
576 /// </summary>
577 /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
578 /// <param name="minX">Minimum X value</param>
579 /// <param name="minY">Minimum Y value</param>
580 /// <param name="maxX">Maximum X value</param>
581 /// <param name="maxY">Maximum Y value</param>
582 /// <returns>Hashtable of hashtables containing map data elements</returns>
583 private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY)
584 {
585 Hashtable param = new Hashtable();
586 param["xmin"] = minX;
587 param["ymin"] = minY;
588 param["xmax"] = maxX;
589 param["ymax"] = maxY;
590 IList parameters = new ArrayList();
591 parameters.Add(param);
592
593 try
594 {
595 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
596 XmlRpcResponse resp = req.Send(serversInfo.GridURL, 10000);
597 Hashtable respData = (Hashtable) resp.Value;
598 return respData;
599 }
600 catch (Exception e)
601 {
602 m_log.Error("MapBlockQuery XMLRPC failure: " + e);
603 return new Hashtable();
604 }
605 }
606
607 /// <summary>
608 /// A ping / version check
609 /// </summary>
610 /// <param name="request"></param>
611 /// <returns></returns>
612 public XmlRpcResponse PingCheckReply(XmlRpcRequest request, IPEndPoint remoteClient)
613 {
614 XmlRpcResponse response = new XmlRpcResponse();
615
616 Hashtable respData = new Hashtable();
617 respData["online"] = "true";
618
619 m_localBackend.PingCheckReply(respData);
620
621 response.Value = respData;
622
623 return response;
624 }
625
626 /// <summary>
627 /// Received from the user server when a user starts logging in. This call allows
628 /// the region to prepare for direct communication from the client. Sends back an empty
629 /// xmlrpc response on completion.
630 /// </summary>
631 /// <param name="request"></param>
632 /// <returns></returns>
633 public XmlRpcResponse ExpectUser(XmlRpcRequest request)
634 {
635 Hashtable requestData = (Hashtable) request.Params[0];
636 AgentCircuitData agentData = new AgentCircuitData();
637 agentData.SessionID = new UUID((string) requestData["session_id"]);
638 agentData.SecureSessionID = new UUID((string) requestData["secure_session_id"]);
639 agentData.firstname = (string) requestData["firstname"];
640 agentData.lastname = (string) requestData["lastname"];
641 agentData.AgentID = new UUID((string) requestData["agent_id"]);
642 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
643 agentData.CapsPath = (string)requestData["caps_path"];
644 ulong regionHandle = Convert.ToUInt64((string) requestData["regionhandle"]);
645
646 // Appearance
647 if (requestData["appearance"] != null)
648 agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]);
649
650 m_log.DebugFormat(
651 "[CLIENT]: Told by user service to prepare for a connection from {0} {1} {2}, circuit {3}",
652 agentData.firstname, agentData.lastname, agentData.AgentID, agentData.circuitcode);
653
654 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
655 {
656 //m_log.Debug("[CLIENT]: Child agent detected");
657 agentData.child = true;
658 }
659 else
660 {
661 //m_log.Debug("[CLIENT]: Main agent detected");
662 agentData.startpos =
663 new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
664 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
665 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
666 agentData.child = false;
667 }
668
669 XmlRpcResponse resp = new XmlRpcResponse();
670
671 if (!RegionLoginsEnabled)
672 {
673 m_log.InfoFormat(
674 "[CLIENT]: Denying access for user {0} {1} because region login is currently disabled",
675 agentData.firstname, agentData.lastname);
676
677 Hashtable respdata = new Hashtable();
678 respdata["success"] = "FALSE";
679 respdata["reason"] = "region login currently disabled";
680 resp.Value = respdata;
681 }
682 else
683 {
684 RegionInfo[] regions = m_regionsOnInstance.ToArray();
685 bool banned = false;
686
687 for (int i = 0; i < regions.Length; i++)
688 {
689 if (regions[i] != null)
690 {
691 if (regions[i].RegionHandle == regionHandle)
692 {
693 if (regions[i].EstateSettings.IsBanned(agentData.AgentID))
694 {
695 banned = true;
696 break;
697 }
698 }
699 }
700 }
701
702 if (banned)
703 {
704 m_log.InfoFormat(
705 "[CLIENT]: Denying access for user {0} {1} because user is banned",
706 agentData.firstname, agentData.lastname);
707
708 Hashtable respdata = new Hashtable();
709 respdata["success"] = "FALSE";
710 respdata["reason"] = "banned";
711 resp.Value = respdata;
712 }
713 else
714 {
715 m_localBackend.TriggerExpectUser(regionHandle, agentData);
716 Hashtable respdata = new Hashtable();
717 respdata["success"] = "TRUE";
718 resp.Value = respdata;
719 }
720 }
721
722 return resp;
723 }
724
725 // Grid Request Processing
726 /// <summary>
727 /// Ooops, our Agent must be dead if we're getting this request!
728 /// </summary>
729 /// <param name="request"></param>
730 /// <returns></returns>
731 public XmlRpcResponse LogOffUser(XmlRpcRequest request)
732 {
733 m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called");
734
735 Hashtable requestData = (Hashtable)request.Params[0];
736 string message = (string)requestData["message"];
737 UUID agentID = UUID.Zero;
738 UUID RegionSecret = UUID.Zero;
739 UUID.TryParse((string)requestData["agent_id"], out agentID);
740 UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
741
742 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
743
744 m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret,message);
745
746 return new XmlRpcResponse();
747 }
748
749 public void NoteDeadRegion(ulong regionhandle)
750 {
751 lock (m_deadRegionCache)
752 {
753 if (m_deadRegionCache.ContainsKey(regionhandle))
754 {
755 m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1;
756 }
757 else
758 {
759 m_deadRegionCache.Add(regionhandle, 1);
760 }
761 }
762 }
763
764 public LandData RequestLandData (ulong regionHandle, uint x, uint y)
765 {
766 m_log.DebugFormat("[OGS1 GRID SERVICES] requests land data in {0}, at {1}, {2}",
767 regionHandle, x, y);
768 LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
769 if (landData == null)
770 {
771 Hashtable hash = new Hashtable();
772 hash["region_handle"] = regionHandle.ToString();
773 hash["x"] = x.ToString();
774 hash["y"] = y.ToString();
775
776 IList paramList = new ArrayList();
777 paramList.Add(hash);
778
779 try
780 {
781 // this might be cached, as we probably requested it just a moment ago...
782 RegionInfo info = RequestNeighbourInfo(regionHandle);
783 if (info != null) // just to be sure
784 {
785 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
786 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
787 XmlRpcResponse response = request.Send(uri, 10000);
788 if (response.IsFault)
789 {
790 m_log.ErrorFormat("[OGS1 GRID SERVICES] remote call returned an error: {0}", response.FaultString);
791 }
792 else
793 {
794 hash = (Hashtable)response.Value;
795 try
796 {
797 landData = new LandData();
798 landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
799 landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
800 landData.Area = Convert.ToInt32(hash["Area"]);
801 landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]);
802 landData.Description = (string)hash["Description"];
803 landData.Flags = Convert.ToUInt32(hash["Flags"]);
804 landData.GlobalID = new UUID((string)hash["GlobalID"]);
805 landData.Name = (string)hash["Name"];
806 landData.OwnerID = new UUID((string)hash["OwnerID"]);
807 landData.SalePrice = Convert.ToInt32(hash["SalePrice"]);
808 landData.SnapshotID = new UUID((string)hash["SnapshotID"]);
809 landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
810 m_log.DebugFormat("[OGS1 GRID SERVICES] Got land data for parcel {0}", landData.Name);
811 }
812 catch (Exception e)
813 {
814 m_log.Error("[OGS1 GRID SERVICES] Got exception while parsing land-data:", e);
815 }
816 }
817 }
818 else m_log.WarnFormat("[OGS1 GRID SERVICES] Couldn't find region with handle {0}", regionHandle);
819 }
820 catch (Exception e)
821 {
822 m_log.ErrorFormat("[OGS1 GRID SERVICES] Couldn't contact region {0}: {1}", regionHandle, e);
823 }
824 }
825 return landData;
826 }
827
828 // Grid Request Processing
829 /// <summary>
830 /// Someone asked us about parcel-information
831 /// </summary>
832 /// <param name="request"></param>
833 /// <returns></returns>
834 public XmlRpcResponse LandData(XmlRpcRequest request, IPEndPoint remoteClient)
835 {
836 Hashtable requestData = (Hashtable)request.Params[0];
837 ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
838 uint x = Convert.ToUInt32(requestData["x"]);
839 uint y = Convert.ToUInt32(requestData["y"]);
840 m_log.DebugFormat("[OGS1 GRID SERVICES]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle);
841
842 LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
843 Hashtable hash = new Hashtable();
844 if (landData != null)
845 {
846 // for now, only push out the data we need for answering a ParcelInfoReqeust
847 hash["AABBMax"] = landData.AABBMax.ToString();
848 hash["AABBMin"] = landData.AABBMin.ToString();
849 hash["Area"] = landData.Area.ToString();
850 hash["AuctionID"] = landData.AuctionID.ToString();
851 hash["Description"] = landData.Description;
852 hash["Flags"] = landData.Flags.ToString();
853 hash["GlobalID"] = landData.GlobalID.ToString();
854 hash["Name"] = landData.Name;
855 hash["OwnerID"] = landData.OwnerID.ToString();
856 hash["SalePrice"] = landData.SalePrice.ToString();
857 hash["SnapshotID"] = landData.SnapshotID.ToString();
858 hash["UserLocation"] = landData.UserLocation.ToString();
859 }
860
861 XmlRpcResponse response = new XmlRpcResponse();
862 response.Value = hash;
863 return response;
864 }
865
866 public List<RegionInfo> RequestNamedRegions (string name, int maxNumber)
867 {
868 // no asking of the local backend first, here, as we have to ask the gridserver anyway.
869 Hashtable hash = new Hashtable();
870 hash["name"] = name;
871 hash["maxNumber"] = maxNumber.ToString();
872
873 IList paramList = new ArrayList();
874 paramList.Add(hash);
875
876 Hashtable result = XmlRpcSearchForRegionByName(paramList);
877 if (result == null) return null;
878
879 uint numberFound = Convert.ToUInt32(result["numFound"]);
880 List<RegionInfo> infos = new List<RegionInfo>();
881 for (int i = 0; i < numberFound; ++i)
882 {
883 string prefix = "region" + i + ".";
884 RegionInfo info = buildRegionInfo(result, prefix);
885 infos.Add(info);
886 }
887 return infos;
888 }
889
890 private RegionInfo buildRegionInfo(Hashtable responseData, string prefix)
891 {
892 uint regX = Convert.ToUInt32((string) responseData[prefix + "region_locx"]);
893 uint regY = Convert.ToUInt32((string) responseData[prefix + "region_locy"]);
894 string internalIpStr = (string) responseData[prefix + "sim_ip"];
895 uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]);
896
897 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int) port);
898
899 RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
900 regionInfo.RemotingPort = Convert.ToUInt32((string) responseData[prefix + "remoting_port"]);
901 regionInfo.RemotingAddress = internalIpStr;
902
903 if (responseData.ContainsKey(prefix + "http_port"))
904 {
905 regionInfo.HttpPort = Convert.ToUInt32((string) responseData[prefix + "http_port"]);
906 }
907
908 regionInfo.RegionID = new UUID((string) responseData[prefix + "region_UUID"]);
909 regionInfo.RegionName = (string) responseData[prefix + "region_name"];
910
911 regionInfo.RegionSettings.TerrainImageID = new UUID((string) responseData[prefix + "map_UUID"]);
912 return regionInfo;
913 }
914
915 private Hashtable XmlRpcSearchForRegionByName(IList parameters)
916 {
917 try
918 {
919 XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters);
920 XmlRpcResponse resp = request.Send(serversInfo.GridURL, 10000);
921 Hashtable respData = (Hashtable) resp.Value;
922 if (respData != null && respData.Contains("faultCode"))
923 {
924 m_log.WarnFormat("[OGS1 GRID SERVICES]: Got an error while contacting GridServer: {0}", respData["faultString"]);
925 return null;
926 }
927
928 return respData;
929 }
930 catch (Exception e)
931 {
932 m_log.Error("[OGS1 GRID SERVICES]: MapBlockQuery XMLRPC failure: ", e);
933 return null;
934 }
935 }
936 }
937}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 49b2b5c..dd9b318 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Communications.Cache;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43 44
44namespace OpenSim.Region.CoreModules.Avatar.Friends 45namespace OpenSim.Region.CoreModules.Avatar.Friends
45{ 46{
@@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
108 private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); 109 private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
109 private IMessageTransferModule m_TransferModule = null; 110 private IMessageTransferModule m_TransferModule = null;
110 111
111 private IGridServices m_gridServices = null; 112 private IGridService m_gridServices = null;
112 113
113 #region IRegionModule Members 114 #region IRegionModule Members
114 115
@@ -142,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
142 if (m_scenes.Count > 0) 143 if (m_scenes.Count > 0)
143 { 144 {
144 m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); 145 m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>();
145 m_gridServices = m_initialScene.CommsManager.GridService; 146 m_gridServices = m_initialScene.GridService;
146 } 147 }
147 if (m_TransferModule == null) 148 if (m_TransferModule == null)
148 m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); 149 m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work");
@@ -171,7 +172,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
171 List<UUID> tpdAway = new List<UUID>(); 172 List<UUID> tpdAway = new List<UUID>();
172 173
173 // destRegionHandle is a region on another server 174 // destRegionHandle is a region on another server
174 RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); 175 uint x = 0, y = 0;
176 Utils.LongToUInts(destRegionHandle, out x, out y);
177 GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
175 if (info != null) 178 if (info != null)
176 { 179 {
177 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; 180 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk";
@@ -223,7 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
223 public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) 226 public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID)
224 { 227 {
225 // destRegionHandle is a region on another server 228 // destRegionHandle is a region on another server
226 RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); 229 uint x = 0, y = 0;
230 Utils.LongToUInts(destRegionHandle, out x, out y);
231 GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y);
227 if (info == null) 232 if (info == null)
228 { 233 {
229 m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); 234 m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle);
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 4495303..e5159b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -36,6 +36,7 @@ using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
41{ 42{
@@ -497,7 +498,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
497 { 498 {
498 if (upd.AgentOnline) 499 if (upd.AgentOnline)
499 { 500 {
500 RegionInfo reginfo = m_Scenes[0].SceneGridService.RequestNeighbouringRegionInfo(upd.Handle); 501 uint x = 0, y = 0;
502 Utils.LongToUInts(upd.Handle, out x, out y);
503 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
504 (int)x, (int)y);
501 if (reginfo != null) 505 if (reginfo != null)
502 { 506 {
503 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); 507 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@@ -559,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
559 /// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param> 563 /// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param>
560 /// <param name="xmlrpcdata">The Instant Message data Hashtable</param> 564 /// <param name="xmlrpcdata">The Instant Message data Hashtable</param>
561 /// <returns>Bool if the message was successfully delivered at the other side.</returns> 565 /// <returns>Bool if the message was successfully delivered at the other side.</returns>
562 protected virtual bool doIMSending(RegionInfo reginfo, Hashtable xmlrpcdata) 566 protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata)
563 { 567 {
564 568
565 ArrayList SendParams = new ArrayList(); 569 ArrayList SendParams = new ArrayList();
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
index ebd9a72..5a9b452 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
@@ -35,6 +35,7 @@ using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38 39
39namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 40namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
40{ 41{
@@ -171,7 +172,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
171 { 172 {
172 // TODO this is the old messaging-server protocol; only the regionHandle is available. 173 // TODO this is the old messaging-server protocol; only the regionHandle is available.
173 // Fetch region-info to get the id 174 // Fetch region-info to get the id
174 RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle); 175 uint x = 0, y = 0;
176 Utils.LongToUInts(info.regionHandle, out x, out y);
177 GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID,
178 (int)x, (int)y);
175 regionID = regionInfo.RegionID; 179 regionID = regionInfo.RegionID;
176 } 180 }
177 result[indices[i]] = new PresenceInfo(uuids[i], regionID); 181 result[indices[i]] = new PresenceInfo(uuids[i], regionID);
@@ -326,6 +330,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
326 330
327 private void NotifyMessageServerOfStartup(Scene scene) 331 private void NotifyMessageServerOfStartup(Scene scene)
328 { 332 {
333 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
334 return;
335
329 Hashtable xmlrpcdata = new Hashtable(); 336 Hashtable xmlrpcdata = new Hashtable();
330 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); 337 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
331 ArrayList SendParams = new ArrayList(); 338 ArrayList SendParams = new ArrayList();
@@ -349,6 +356,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
349 356
350 private void NotifyMessageServerOfShutdown(Scene scene) 357 private void NotifyMessageServerOfShutdown(Scene scene)
351 { 358 {
359 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
360 return;
361
352 Hashtable xmlrpcdata = new Hashtable(); 362 Hashtable xmlrpcdata = new Hashtable();
353 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); 363 xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString();
354 ArrayList SendParams = new ArrayList(); 364 ArrayList SendParams = new ArrayList();
@@ -372,6 +382,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
372 382
373 private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) 383 private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle)
374 { 384 {
385 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
386 return;
387
375 Hashtable xmlrpcdata = new Hashtable(); 388 Hashtable xmlrpcdata = new Hashtable();
376 xmlrpcdata["AgentID"] = agentID.ToString(); 389 xmlrpcdata["AgentID"] = agentID.ToString();
377 xmlrpcdata["RegionUUID"] = region.ToString(); 390 xmlrpcdata["RegionUUID"] = region.ToString();
@@ -397,6 +410,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
397 410
398 private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) 411 private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle)
399 { 412 {
413 if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty)
414 return;
415
400 Hashtable xmlrpcdata = new Hashtable(); 416 Hashtable xmlrpcdata = new Hashtable();
401 xmlrpcdata["AgentID"] = agentID.ToString(); 417 xmlrpcdata["AgentID"] = agentID.ToString();
402 xmlrpcdata["RegionUUID"] = region.ToString(); 418 xmlrpcdata["RegionUUID"] = region.ToString();
diff --git a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs b/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs
deleted file mode 100644
index 8c92727..0000000
--- a/OpenSim/Region/CoreModules/Framework/Services/RegionMapService.cs
+++ /dev/null
@@ -1,208 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using log4net;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43
44using Nwc.XmlRpc;
45
46
47namespace OpenSim.Region.CoreModules.Framework.Services
48{
49 public class RegionMapService : IRegionModule
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private static bool initialized = false;
53 private static bool enabled = false;
54
55 Scene m_scene;
56 //AssetService m_assetService;
57
58 #region IRegionModule interface
59
60 public void Initialise(Scene scene, IConfigSource config)
61 {
62 if (!initialized)
63 {
64 initialized = true;
65 m_scene = scene;
66
67 // This module is only on for hypergrid mode
68 enabled = config.Configs["Startup"].GetBoolean("hypergrid", false);
69 }
70 }
71
72 public void PostInitialise()
73 {
74 if (enabled)
75 {
76 m_log.Info("[RegionMapService]: Starting...");
77
78 //m_assetService = new AssetService(m_scene);
79 new GridService(m_scene);
80 }
81 }
82
83 public void Close()
84 {
85 }
86
87 public string Name
88 {
89 get { return "RegionMapService"; }
90 }
91
92 public bool IsSharedModule
93 {
94 get { return true; }
95 }
96
97 #endregion
98
99 }
100
101 public class GridService
102 {
103// private IUserService m_userService;
104 private IGridServices m_gridService;
105 private bool m_doLookup = false;
106
107 public bool DoLookup
108 {
109 get { return m_doLookup; }
110 set { m_doLookup = value; }
111 }
112 private static readonly ILog m_log
113 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
114
115 public GridService(Scene m_scene)
116 {
117 AddHandlers(m_scene);
118// m_userService = m_scene.CommsManager.UserService;
119 m_gridService = m_scene.CommsManager.GridService;
120 }
121
122 protected void AddHandlers(Scene m_scene)
123 {
124// IAssetDataPlugin m_assetProvider
125// = ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin;
126
127 IHttpServer httpServer = MainServer.Instance;
128 httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod);
129 //m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod);
130 //m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod);
131
132 }
133
134 /// <summary>
135 /// Returns an XML RPC response to a simulator profile request
136 /// </summary>
137 /// <param name="request"></param>
138 /// <returns></returns>
139 public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request, IPEndPoint remoteClient)
140 {
141 Hashtable requestData = (Hashtable)request.Params[0];
142 Hashtable responseData = new Hashtable();
143 RegionInfo simData = null;
144 if (requestData.ContainsKey("region_UUID"))
145 {
146 UUID regionID = new UUID((string)requestData["region_UUID"]);
147 simData = m_gridService.RequestNeighbourInfo(regionID); //.GetRegion(regionID);
148 if (simData == null)
149 {
150 m_log.WarnFormat("[HGGridService] didn't find region for regionID {0} from {1}",
151 regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
152 }
153 }
154 else if (requestData.ContainsKey("region_handle"))
155 {
156 //CFK: The if/else below this makes this message redundant.
157 //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]);
158 ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]);
159 simData = m_gridService.RequestNeighbourInfo(regionHandle); //m_gridDBService.GetRegion(regionHandle);
160 if (simData == null)
161 {
162 m_log.WarnFormat("[HGGridService] didn't find region for regionHandle {0} from {1}",
163 regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
164 }
165 }
166 else if (requestData.ContainsKey("region_name_search"))
167 {
168 string regionName = (string)requestData["region_name_search"];
169 List<RegionInfo> regInfos = m_gridService.RequestNamedRegions(regionName, 1);//m_gridDBService.GetRegion(regionName);
170 if (regInfos != null)
171 simData = regInfos[0];
172
173 if (simData == null)
174 {
175 m_log.WarnFormat("[HGGridService] didn't find region for regionName {0} from {1}",
176 regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
177 }
178 }
179 else m_log.Warn("[HGGridService] regionlookup without regionID, regionHandle or regionHame");
180
181 if (simData == null)
182 {
183 //Sim does not exist
184 responseData["error"] = "Sim does not exist";
185 }
186 else
187 {
188 m_log.Debug("[HGGridService]: found " + (string)simData.RegionName + " regionHandle = " +
189 (string)requestData["region_handle"]);
190 responseData["sim_ip"] = simData.ExternalEndPoint.Address.ToString();
191 responseData["sim_port"] = simData.ExternalEndPoint.Port.ToString();
192 //responseData["server_uri"] = simData.serverURI;
193 responseData["http_port"] = simData.HttpPort.ToString();
194 //responseData["remoting_port"] = simData.remotingPort.ToString();
195 responseData["region_locx"] = simData.RegionLocX.ToString();
196 responseData["region_locy"] = simData.RegionLocY.ToString();
197 responseData["region_UUID"] = simData.RegionID.ToString();
198 responseData["region_name"] = simData.RegionName;
199 responseData["region_secret"] = simData.regionSecret;
200 }
201
202 XmlRpcResponse response = new XmlRpcResponse();
203 response.Value = responseData;
204 return response;
205 }
206
207 }
208}
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
index 6774060..a0ccdc7 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
34using OpenSim.Region.CoreModules.World.WorldMap; 34using OpenSim.Region.CoreModules.World.WorldMap;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37 38
38namespace OpenSim.Region.CoreModules.Hypergrid 39namespace OpenSim.Region.CoreModules.Hypergrid
39{ 40{
@@ -59,7 +60,17 @@ namespace OpenSim.Region.CoreModules.Hypergrid
59 60
60 protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 61 protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
61 { 62 {
62 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); 63 List<MapBlockData> mapBlocks = new List<MapBlockData>();
64 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
65 (minX - 4) * (int)Constants.RegionSize, (maxX + 4) * (int)Constants.RegionSize,
66 (minY - 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize);
67
68 foreach (GridRegion r in regions)
69 {
70 MapBlockData block = new MapBlockData();
71 MapBlockFromGridRegion(block, r);
72 mapBlocks.Add(block);
73 }
63 74
64 // Different from super 75 // Different from super
65 FillInMap(mapBlocks, minX, minY, maxX, maxY); 76 FillInMap(mapBlocks, minX, minY, maxX, maxY);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
index 4fbee7f..9bf31a4 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
@@ -37,6 +37,8 @@ using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Grid; 39using OpenSim.Server.Handlers.Grid;
40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 42
41namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid 43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
42{ 44{
@@ -94,20 +96,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
94 if (!m_Enabled) 96 if (!m_Enabled)
95 return; 97 return;
96 98
97 if (!m_Registered)
98 {
99 m_Registered = true;
100
101 m_log.Info("[HypergridService]: Starting...");
102
103 Object[] args = new Object[] { m_Config, MainServer.Instance };
104
105 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
106 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
107 }
108
109 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
110 m_HypergridHandler.AddRegion(rinfo);
111 } 99 }
112 100
113 public void RemoveRegion(Scene scene) 101 public void RemoveRegion(Scene scene)
@@ -115,12 +103,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
115 if (!m_Enabled) 103 if (!m_Enabled)
116 return; 104 return;
117 105
118 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); 106 GridRegion rinfo = new GridRegion(scene.RegionInfo);
119 m_HypergridHandler.RemoveRegion(rinfo); 107 m_HypergridHandler.RemoveRegion(rinfo);
120 } 108 }
121 109
122 public void RegionLoaded(Scene scene) 110 public void RegionLoaded(Scene scene)
123 { 111 {
112 if (!m_Registered)
113 {
114 m_Registered = true;
115
116 m_log.Info("[HypergridService]: Starting...");
117
118 Object[] args = new Object[] { m_Config, MainServer.Instance };
119
120 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>());
121 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
122 }
123
124 GridRegion rinfo = new GridRegion(scene.RegionInfo);
125 m_HypergridHandler.AddRegion(rinfo);
124 } 126 }
125 127
126 #endregion 128 #endregion
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
index a31ce8e..8a90370 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
121 121
122 #region INeighbourService 122 #region INeighbourService
123 123
124 public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 124 public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
125 { 125 {
126 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", 126 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
127 thisRegion.RegionName, regionHandle, m_Scenes.Count); 127 thisRegion.RegionName, regionHandle, m_Scenes.Count);
@@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour
134 } 134 }
135 } 135 }
136 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle); 136 m_log.DebugFormat("[NEIGHBOUR IN CONNECTOR]: region handle {0} not found", regionHandle);
137 return false; 137 return null;
138 } 138 }
139 139
140 #endregion INeighbourService 140 #endregion INeighbourService
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
index 36915ef..0974372 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
86 86
87 private void RunHGCommand(string command, string[] cmdparams) 87 private void RunHGCommand(string command, string[] cmdparams)
88 { 88 {
89 if (command.Equals("linkk-mapping")) 89 if (command.Equals("link-mapping"))
90 { 90 {
91 if (cmdparams.Length == 2) 91 if (cmdparams.Length == 2)
92 { 92 {
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
104 } 104 }
105 } 105 }
106 } 106 }
107 else if (command.Equals("linkk-region")) 107 else if (command.Equals("link-region"))
108 { 108 {
109 if (cmdparams.Length < 3) 109 if (cmdparams.Length < 3)
110 { 110 {
@@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
187 } 187 }
188 return; 188 return;
189 } 189 }
190 else if (command.Equals("unlinkk-region")) 190 else if (command.Equals("unlink-region"))
191 { 191 {
192 if (cmdparams.Length < 1) 192 if (cmdparams.Length < 1)
193 { 193 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 0c2a835..1eb481e 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -31,6 +31,7 @@ using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Xml; 32using System.Xml;
33 33
34using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -47,15 +48,19 @@ using Nini.Config;
47 48
48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 49namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
49{ 50{
50 public class HGGridConnector : ISharedRegionModule, IGridService 51 public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService
51 { 52 {
52 private static readonly ILog m_log = 53 private static readonly ILog m_log =
53 LogManager.GetLogger( 54 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
56 private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
55 57
56 private bool m_Enabled = false; 58 private bool m_Enabled = false;
57 private bool m_Initialized = false; 59 private bool m_Initialized = false;
58 60
61 private Scene m_aScene;
62 private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
63
59 private IGridService m_GridServiceConnector; 64 private IGridService m_GridServiceConnector;
60 private HypergridServiceConnector m_HypergridServiceConnector; 65 private HypergridServiceConnector m_HypergridServiceConnector;
61 66
@@ -130,6 +135,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
130 135
131 public void PostInitialise() 136 public void PostInitialise()
132 { 137 {
138 if (m_Enabled)
139 ((ISharedRegionModule)m_GridServiceConnector).PostInitialise();
133 } 140 }
134 141
135 public void Close() 142 public void Close()
@@ -141,12 +148,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
141 if (!m_Enabled) 148 if (!m_Enabled)
142 return; 149 return;
143 150
151 m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
144 scene.RegisterModuleInterface<IGridService>(this); 152 scene.RegisterModuleInterface<IGridService>(this);
153 scene.RegisterModuleInterface<IHyperlinkService>(this);
154
155 ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
145 156
146 } 157 }
147 158
148 public void RemoveRegion(Scene scene) 159 public void RemoveRegion(Scene scene)
149 { 160 {
161 if (m_Enabled)
162 {
163 m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
164 ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene);
165 }
150 } 166 }
151 167
152 public void RegionLoaded(Scene scene) 168 public void RegionLoaded(Scene scene)
@@ -156,29 +172,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
156 172
157 if (!m_Initialized) 173 if (!m_Initialized)
158 { 174 {
175 m_aScene = scene;
176 LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
177 LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL;
178 LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
179
159 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); 180 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
181
160 HGCommands hgCommands = new HGCommands(this, scene); 182 HGCommands hgCommands = new HGCommands(this, scene);
161 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region", 183 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
162 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", 184 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
163 "Link a hypergrid region", hgCommands.RunCommand); 185 "Link a hypergrid region", hgCommands.RunCommand);
164 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region", 186 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region",
165 "unlink-region <local name> or <HostName>:<HttpPort> <cr>", 187 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
166 "Unlink a hypergrid region", hgCommands.RunCommand); 188 "Unlink a hypergrid region", hgCommands.RunCommand);
167 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [<x> <y>] <cr>", 189 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
168 "Set local coordinate to map HG regions to", hgCommands.RunCommand); 190 "Set local coordinate to map HG regions to", hgCommands.RunCommand);
169 m_Initialized = true;
170 }
171 191
192 // Yikes!! Remove this as soon as user services get refactored
193 HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
172 194
173 //scene.AddCommand("HGGridServicesConnector", "linkk-region", 195 m_Initialized = true;
174 // "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", 196 }
175 // "Link a hypergrid region", hgCommands.RunCommand);
176 //scene.AddCommand("HGGridServicesConnector", "unlinkk-region",
177 // "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
178 // "Unlink a hypergrid region", hgCommands.RunCommand);
179 //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [<x> <y>] <cr>",
180 // "Set local coordinate to map HG regions to", hgCommands.RunCommand);
181
182 } 197 }
183 198
184 #endregion 199 #endregion
@@ -250,7 +265,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
250 // Try the foreign users home collection 265 // Try the foreign users home collection
251 foreach (GridRegion r in m_knownRegions.Values) 266 foreach (GridRegion r in m_knownRegions.Values)
252 if (r.RegionID == regionID) 267 if (r.RegionID == regionID)
253 return m_knownRegions[regionID]; 268 return r;
254 269
255 // Finally, try the normal route 270 // Finally, try the normal route
256 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); 271 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
@@ -271,7 +286,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
271 foreach (GridRegion r in m_knownRegions.Values) 286 foreach (GridRegion r in m_knownRegions.Values)
272 { 287 {
273 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) 288 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
289 {
274 return r; 290 return r;
291 }
275 } 292 }
276 293
277 // Finally, try the normal route 294 // Finally, try the normal route
@@ -338,8 +355,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
338 355
339 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) 356 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
340 { 357 {
341 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); 358 m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
342 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 359 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
343 } 360 }
344 361
345 private void RemoveHyperlinkRegion(UUID regionID) 362 private void RemoveHyperlinkRegion(UUID regionID)
@@ -350,8 +367,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
350 367
351 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) 368 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
352 { 369 {
353 m_knownRegions.Add(userID, regionInfo); 370 m_knownRegions[userID] = regionInfo;
354 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); 371 m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
355 } 372 }
356 373
357 private void RemoveHyperlinkHomeRegion(UUID regionID) 374 private void RemoveHyperlinkHomeRegion(UUID regionID)
@@ -367,10 +384,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
367 } 384 }
368 #endregion 385 #endregion
369 386
370 #region Hyperlinks 387 #region IHyperlinkService
371 388
372 private static Random random = new Random(); 389 private static Random random = new Random();
373 390
391
374 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) 392 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
375 { 393 {
376 string host = "127.0.0.1"; 394 string host = "127.0.0.1";
@@ -417,10 +435,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
417 return null; 435 return null;
418 } 436 }
419 437
438
420 // From the map search and secondlife://blah 439 // From the map search and secondlife://blah
421 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 440 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
422 { 441 {
423 int xloc = random.Next(0, Int16.MaxValue); 442 int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize;
424 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 443 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
425 } 444 }
426 445
@@ -447,15 +466,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
447 } 466 }
448 467
449 // Finally, link it 468 // Finally, link it
450 try 469 if (!RegisterRegion(UUID.Zero, regInfo))
451 { 470 {
452 RegisterRegion(UUID.Zero, regInfo); 471 m_log.Warn("[HGrid]: Unable to link region");
453 } 472 return false;
454 catch (Exception e) 473 }
455 {
456 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
457 return false;
458 }
459 474
460 int x, y; 475 int x, y;
461 if (!Check4096(m_scene, regInfo, out x, out y)) 476 if (!Check4096(m_scene, regInfo, out x, out y))
@@ -554,7 +569,227 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
554 return true; 569 return true;
555 } 570 }
556 571
572 public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor)
573 {
574 return TryLinkRegion((Scene)client.Scene, client, regionDescriptor);
575 }
576
577 public GridRegion GetHyperlinkRegion(ulong handle)
578 {
579 foreach (GridRegion r in m_HyperlinkRegions.Values)
580 if (r.RegionHandle == handle)
581 return r;
582 foreach (GridRegion r in m_knownRegions.Values)
583 if (r.RegionHandle == handle)
584 return r;
585 return null;
586 }
587
588 public ulong FindRegionHandle(ulong handle)
589 {
590 foreach (GridRegion r in m_HyperlinkRegions.Values)
591 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
592 return m_HyperlinkHandles[r.RegionID];
593
594 foreach (GridRegion r in m_knownRegions.Values)
595 if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
596 return m_HyperlinkHandles[r.RegionID];
597
598 return handle;
599 }
600
601 public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
602 {
603 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
604
605 if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
606 (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
607 {
608 m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
609
610 // Set the position of the region on the remote grid
611 ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
612 uint x = 0, y = 0;
613 Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
614 GridRegion clonedRegion = new GridRegion(regInfo);
615 clonedRegion.RegionLocX = (int)x;
616 clonedRegion.RegionLocY = (int)y;
617
618 // Get the user's home region information
619 GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
620
621 // Get the user's service URLs
622 string serverURI = "";
623 if (uinfo.UserProfile is ForeignUserProfileData)
624 serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
625 string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
626
627 string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
628 if ((assetServer == null) || (assetServer == ""))
629 assetServer = LocalAssetServerURI;
630
631 string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
632 if ((inventoryServer == null) || (inventoryServer == ""))
633 inventoryServer = LocalInventoryServerURI;
634
635 if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
636 {
637 m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
638 return false;
639 }
640 }
641 //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
642 //{
643 // m_log.Info("[HGrid]: User seems to be going to foreign region.");
644 // if (!InformRegionOfUser(regInfo, agentData))
645 // {
646 // m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
647 // return false;
648 // }
649 //}
650 //else
651 // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
652
653 // May need to change agent's name
654 if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
655 {
656 agentData.firstname = agentData.firstname + "." + agentData.lastname;
657 agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
658 }
659
660 return true;
661 }
662
663 public void AdjustUserInformation(AgentCircuitData agentData)
664 {
665 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
666 if ((uinfo != null) && (uinfo.UserProfile != null) &&
667 (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
668 {
669 //m_log.Debug("---------------> Local User!");
670 string[] parts = agentData.firstname.Split(new char[] { '.' });
671 if (parts.Length == 2)
672 {
673 agentData.firstname = parts[0];
674 agentData.lastname = parts[1];
675 }
676 }
677 //else
678 // m_log.Debug("---------------> Foreign User!");
679 }
680
681 // Check if a local user exists with the same UUID as the incoming foreign user
682 public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome)
683 {
684 comingHome = false;
685 if (!m_aScene.SceneGridService.RegionLoginsEnabled)
686 return false;
687
688 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
689 if (uinfo != null)
690 {
691 // uh-oh we have a potential intruder
692 if (uinfo.SessionID != sessionID)
693 // can't have a foreigner with a local UUID
694 return false;
695 else
696 // oh, so it's you! welcome back
697 comingHome = true;
698 }
699
700 // OK, user can come in
701 return true;
702 }
703
704 public void AcceptUser(ForeignUserProfileData user, GridRegion home)
705 {
706 m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
707 ulong realHandle = home.RegionHandle;
708 // Change the local coordinates
709 // X=0 on the map
710 home.RegionLocX = 0;
711 home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
712
713 AddHyperlinkHomeRegion(user.ID, home, realHandle);
714
715 DumpUserData(user);
716 DumpRegionData(home);
717
718 }
719
720 public bool IsLocalUser(UUID userID)
721 {
722 CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
723 return IsLocalUser(uinfo);
724 }
725
557 #endregion 726 #endregion
558 727
728 #region IHyperlink Misc
729
730 protected bool IsComingHome(ForeignUserProfileData userData)
731 {
732 return (userData.UserServerURI == LocalUserServerURI);
733 }
734
735 // Is the user going back to the home region or the home grid?
736 protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
737 {
738 if (uinfo.UserProfile == null)
739 return false;
740
741 if (!(uinfo.UserProfile is ForeignUserProfileData))
742 // it's a home user, can't be outside to return home
743 return false;
744
745 // OK, it's a foreign user with a ForeignUserProfileData
746 // and is going back to exactly the home region.
747 // We can't check if it's going back to a non-home region
748 // of the home grid. That will be dealt with in the
749 // receiving end
750 return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
751 }
752
753 protected bool IsLocalUser(CachedUserInfo uinfo)
754 {
755 if (uinfo == null)
756 return false;
757
758 return !(uinfo.UserProfile is ForeignUserProfileData);
759
760 }
761
762 protected bool IsLocalRegion(ulong handle)
763 {
764 return m_LocalScenes.ContainsKey(handle);
765 }
766
767 private void DumpUserData(ForeignUserProfileData userData)
768 {
769 m_log.Info(" ------------ User Data Dump ----------");
770 m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
771 m_log.Info(" >> HomeID: " + userData.HomeRegionID);
772 m_log.Info(" >> UserServer: " + userData.UserServerURI);
773 m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
774 m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
775 m_log.Info(" ------------ -------------- ----------");
776 }
777
778 private void DumpRegionData(GridRegion rinfo)
779 {
780 m_log.Info(" ------------ Region Data Dump ----------");
781 m_log.Info(" >> handle: " + rinfo.RegionHandle);
782 m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
783 m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
784 m_log.Info(" >> http port: " + rinfo.HttpPort);
785 m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
786 m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
787 m_log.Info(" ------------ -------------- ----------");
788 }
789
790
791 #endregion
792
793
559 } 794 }
560} 795}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 743d3b9..6c2928a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -31,6 +31,7 @@ using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
47 LogManager.GetLogger( 48 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 49 MethodBase.GetCurrentMethod().DeclaringType);
49 50
51 private static LocalGridServicesConnector m_MainInstance;
52
50 private IGridService m_GridService; 53 private IGridService m_GridService;
54 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
51 55
52 private bool m_Enabled = false; 56 private bool m_Enabled = false;
53 57
@@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
58 public LocalGridServicesConnector(IConfigSource source) 62 public LocalGridServicesConnector(IConfigSource source)
59 { 63 {
60 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); 64 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
65 m_MainInstance = this;
61 InitialiseService(source); 66 InitialiseService(source);
62 } 67 }
63 68
@@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
82 if (name == Name) 87 if (name == Name)
83 { 88 {
84 InitialiseService(source); 89 InitialiseService(source);
90 m_MainInstance = this;
85 m_Enabled = true; 91 m_Enabled = true;
86 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); 92 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
87 } 93 }
@@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
120 126
121 public void PostInitialise() 127 public void PostInitialise()
122 { 128 {
129 if (m_MainInstance == this)
130 {
131 MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours",
132 "show neighbours",
133 "Shows the local regions' neighbours", NeighboursCommand);
134 }
123 } 135 }
124 136
125 public void Close() 137 public void Close()
@@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
128 140
129 public void AddRegion(Scene scene) 141 public void AddRegion(Scene scene)
130 { 142 {
131 if (!m_Enabled) 143 if (m_Enabled)
132 return; 144 scene.RegisterModuleInterface<IGridService>(this);
145
146 if (m_MainInstance == this)
147 {
148 if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
149 m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
150 else
151 m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
133 152
134 scene.RegisterModuleInterface<IGridService>(this); 153 }
135 } 154 }
136 155
137 public void RemoveRegion(Scene scene) 156 public void RemoveRegion(Scene scene)
138 { 157 {
158 if (m_MainInstance == this)
159 {
160 m_LocalCache[scene.RegionInfo.RegionID].Clear();
161 m_LocalCache.Remove(scene.RegionInfo.RegionID);
162 }
139 } 163 }
140 164
141 public void RegionLoaded(Scene scene) 165 public void RegionLoaded(Scene scene)
@@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
158 182
159 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) 183 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
160 { 184 {
161 return m_GridService.GetNeighbours(scopeID, regionID); 185 if (m_LocalCache.ContainsKey(regionID))
186 {
187 return m_LocalCache[regionID].GetNeighbours();
188 }
189 else
190 {
191 m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID);
192 return new List<GridRegion>();
193 }
194
195 // Don't go to the DB
196 //return m_GridService.GetNeighbours(scopeID, regionID);
162 } 197 }
163 198
164 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 199 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
@@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
187 } 222 }
188 223
189 #endregion 224 #endregion
225
226 public void NeighboursCommand(string module, string[] cmdparams)
227 {
228 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
229 {
230 m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName);
231 List<GridRegion> regions = kvp.Value.GetNeighbours();
232 foreach (GridRegion r in regions)
233 m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
234 }
235 }
190 } 236 }
191} 237}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
new file mode 100644
index 0000000..ea205a2
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
@@ -0,0 +1,52 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using OpenSim.Region.Framework.Scenes;
6using OpenSim.Services.Interfaces;
7using GridRegion = OpenSim.Services.Interfaces.GridRegion;
8
9using log4net;
10
11namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
12{
13 public class RegionCache
14 {
15 private static readonly ILog m_log =
16 LogManager.GetLogger(
17 MethodBase.GetCurrentMethod().DeclaringType);
18
19 private Scene m_scene;
20 private Dictionary<ulong, GridRegion> m_neighbours = new Dictionary<ulong, GridRegion>();
21
22 public string RegionName
23 {
24 get { return m_scene.RegionInfo.RegionName; }
25 }
26
27 public RegionCache(Scene s)
28 {
29 m_scene = s;
30 m_scene.EventManager.OnRegionUp += OnRegionUp;
31 }
32
33 private void OnRegionUp(GridRegion otherRegion)
34 {
35 m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
36 m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
37
38 m_neighbours[otherRegion.RegionHandle] = otherRegion;
39 }
40
41 public void Clear()
42 {
43 m_scene.EventManager.OnRegionUp -= OnRegionUp;
44 m_neighbours.Clear();
45 }
46
47 public List<GridRegion> GetNeighbours()
48 {
49 return new List<GridRegion>(m_neighbours.Values);
50 }
51 }
52}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 91a808b..72c00fc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
104 104
105 public void PostInitialise() 105 public void PostInitialise()
106 { 106 {
107 if (m_LocalGridService != null)
108 ((ISharedRegionModule)m_LocalGridService).PostInitialise();
107 } 109 }
108 110
109 public void Close() 111 public void Close()
@@ -112,14 +114,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
112 114
113 public void AddRegion(Scene scene) 115 public void AddRegion(Scene scene)
114 { 116 {
115 if (!m_Enabled) 117 if (m_Enabled)
116 return; 118 scene.RegisterModuleInterface<IGridService>(this);
117 119
118 scene.RegisterModuleInterface<IGridService>(this); 120 if (m_LocalGridService != null)
121 ((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
119 } 122 }
120 123
121 public void RemoveRegion(Scene scene) 124 public void RemoveRegion(Scene scene)
122 { 125 {
126 if (m_LocalGridService != null)
127 ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
123 } 128 }
124 129
125 public void RegionLoaded(Scene scene) 130 public void RegionLoaded(Scene scene)
@@ -146,7 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
146 return false; 151 return false;
147 } 152 }
148 153
149 // Let's not override GetNeighbours -- let's get them all from the grid server 154 // Let's override GetNeighbours completely -- never go to the grid server
155 // Neighbours are/should be cached locally
156 // For retrieval from the DB, caller should call GetRegionByPosition
157 public override List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
158 {
159 return m_LocalGridService.GetNeighbours(scopeID, regionID);
160 }
150 161
151 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 162 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
152 { 163 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
index 9519e23..696225c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs
@@ -42,6 +42,8 @@ using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Hypergrid; 43using OpenSim.Region.Framework.Scenes.Hypergrid;
44using OpenSim.Region.Framework.Scenes.Serialization; 44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Services.Interfaces;
46using GridRegion = OpenSim.Services.Interfaces.GridRegion;
45 47
46namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion 48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
47{ 49{
@@ -59,6 +61,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
59 61
60 protected RegionToRegionClient m_regionClient; 62 protected RegionToRegionClient m_regionClient;
61 63
64 protected IHyperlinkService m_hyperlinkService;
65
62 protected bool m_safemode; 66 protected bool m_safemode;
63 protected IPAddress m_thisIP; 67 protected IPAddress m_thisIP;
64 68
@@ -134,7 +138,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
134 m_localBackend = new LocalInterregionComms(); 138 m_localBackend = new LocalInterregionComms();
135 m_commsManager = scene.CommsManager; 139 m_commsManager = scene.CommsManager;
136 m_aScene = scene; 140 m_aScene = scene;
137 m_regionClient = new RegionToRegionClient(m_aScene); 141 m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>();
142 m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
138 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); 143 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
139 } 144 }
140 145
@@ -161,7 +166,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
161 // else do the remote thing 166 // else do the remote thing
162 if (!m_localBackend.IsLocalRegion(regionHandle)) 167 if (!m_localBackend.IsLocalRegion(regionHandle))
163 { 168 {
164 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 169 uint x = 0, y = 0;
170 Utils.LongToUInts(regionHandle, out x, out y);
171 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
165 if (regInfo != null) 172 if (regInfo != null)
166 { 173 {
167 m_regionClient.SendUserInformation(regInfo, aCircuit); 174 m_regionClient.SendUserInformation(regInfo, aCircuit);
@@ -183,7 +190,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
183 // else do the remote thing 190 // else do the remote thing
184 if (!m_localBackend.IsLocalRegion(regionHandle)) 191 if (!m_localBackend.IsLocalRegion(regionHandle))
185 { 192 {
186 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 193 uint x = 0, y = 0;
194 Utils.LongToUInts(regionHandle, out x, out y);
195 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
187 if (regInfo != null) 196 if (regInfo != null)
188 { 197 {
189 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); 198 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -204,7 +213,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
204 // else do the remote thing 213 // else do the remote thing
205 if (!m_localBackend.IsLocalRegion(regionHandle)) 214 if (!m_localBackend.IsLocalRegion(regionHandle))
206 { 215 {
207 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 216 uint x = 0, y = 0;
217 Utils.LongToUInts(regionHandle, out x, out y);
218 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
208 if (regInfo != null) 219 if (regInfo != null)
209 { 220 {
210 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); 221 return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
@@ -225,7 +236,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
225 // else do the remote thing 236 // else do the remote thing
226 if (!m_localBackend.IsLocalRegion(regionHandle)) 237 if (!m_localBackend.IsLocalRegion(regionHandle))
227 { 238 {
228 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 239 uint x = 0, y = 0;
240 Utils.LongToUInts(regionHandle, out x, out y);
241 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
229 if (regInfo != null) 242 if (regInfo != null)
230 { 243 {
231 return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); 244 return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent);
@@ -257,7 +270,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
257 // else do the remote thing 270 // else do the remote thing
258 if (!m_localBackend.IsLocalRegion(regionHandle)) 271 if (!m_localBackend.IsLocalRegion(regionHandle))
259 { 272 {
260 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 273 uint x = 0, y = 0;
274 Utils.LongToUInts(regionHandle, out x, out y);
275 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
261 if (regInfo != null) 276 if (regInfo != null)
262 { 277 {
263 return m_regionClient.DoCloseAgentCall(regInfo, id); 278 return m_regionClient.DoCloseAgentCall(regInfo, id);
@@ -284,7 +299,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
284 // else do the remote thing 299 // else do the remote thing
285 if (!m_localBackend.IsLocalRegion(regionHandle)) 300 if (!m_localBackend.IsLocalRegion(regionHandle))
286 { 301 {
287 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); 302 uint x = 0, y = 0;
303 Utils.LongToUInts(regionHandle, out x, out y);
304 GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
288 if (regInfo != null) 305 if (regInfo != null)
289 { 306 {
290 return m_regionClient.DoCreateObjectCall( 307 return m_regionClient.DoCreateObjectCall(
@@ -776,16 +793,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
776 protected class RegionToRegionClient : RegionClient 793 protected class RegionToRegionClient : RegionClient
777 { 794 {
778 Scene m_aScene = null; 795 Scene m_aScene = null;
796 IHyperlinkService m_hyperlinkService;
779 797
780 public RegionToRegionClient(Scene s) 798 public RegionToRegionClient(Scene s, IHyperlinkService hyperService)
781 { 799 {
782 m_aScene = s; 800 m_aScene = s;
801 m_hyperlinkService = hyperService;
783 } 802 }
784 803
785 public override ulong GetRegionHandle(ulong handle) 804 public override ulong GetRegionHandle(ulong handle)
786 { 805 {
787 if (m_aScene.SceneGridService is HGSceneCommunicationService) 806 if (m_aScene.SceneGridService is HGSceneCommunicationService)
788 return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.FindRegionHandle(handle); 807 {
808 if (m_hyperlinkService != null)
809 return m_hyperlinkService.FindRegionHandle(handle);
810 }
789 811
790 return handle; 812 return handle;
791 } 813 }
@@ -793,29 +815,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
793 public override bool IsHyperlink(ulong handle) 815 public override bool IsHyperlink(ulong handle)
794 { 816 {
795 if (m_aScene.SceneGridService is HGSceneCommunicationService) 817 if (m_aScene.SceneGridService is HGSceneCommunicationService)
796 return ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.IsHyperlinkRegion(handle); 818 {
797 819 if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null))
820 return true;
821 }
798 return false; 822 return false;
799 } 823 }
800 824
801 public override void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit) 825 public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
802 { 826 {
803 try 827 if (m_hyperlinkService != null)
804 { 828 m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
805 if (m_aScene.SceneGridService is HGSceneCommunicationService)
806 {
807 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit);
808 }
809 }
810 catch // Bad cast
811 { }
812 829
813 } 830 }
814 831
815 public override void AdjustUserInformation(AgentCircuitData aCircuit) 832 public override void AdjustUserInformation(AgentCircuitData aCircuit)
816 { 833 {
817 if (m_aScene.SceneGridService is HGSceneCommunicationService) 834 if (m_hyperlinkService != null)
818 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit); 835 m_hyperlinkService.AdjustUserInformation(aCircuit);
819 } 836 }
820 } 837 }
821 838
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1c66254..fd1a759 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
525 return true; 525 return true;
526 } 526 }
527 527
528 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 528 if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == ""))
529 // this happens in standalone profiles, apparently
530 return true;
531
532 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
533
529 string uri = m_LocalGridInventoryURI.TrimEnd('/'); 534 string uri = m_LocalGridInventoryURI.TrimEnd('/');
530 535
531 if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) 536 if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
@@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
544 if ((uinfo == null) || (uinfo.UserProfile == null)) 549 if ((uinfo == null) || (uinfo.UserProfile == null))
545 return invURI; 550 return invURI;
546 551
547 string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); 552 string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
548 553
549 if ((userInventoryServerURI != null) && 554 if ((userInventoryServerURI != null) &&
550 (userInventoryServerURI != "")) 555 (userInventoryServerURI != ""))
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
index a52c70b..b0ace39 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39 39
40
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
41{ 42{
42 public class RemoteLandServicesConnector : 43 public class RemoteLandServicesConnector :
@@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land
89 if (!m_Enabled) 90 if (!m_Enabled)
90 return; 91 return;
91 92
92 m_MapService = scene.CommsManager.GridService; 93 m_GridService = scene.GridService;
93 m_LocalService.AddRegion(scene); 94 m_LocalService.AddRegion(scene);
94 scene.RegisterModuleInterface<ILandService>(this); 95 scene.RegisterModuleInterface<ILandService>(this);
95 } 96 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
index 61bf481..daba0b3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
119 119
120 #region INeighbourService 120 #region INeighbourService
121 121
122 public bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 122 public GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
123 { 123 {
124 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}", 124 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: HelloNeighbour from {0}, to {1}. Count = {2}",
125 thisRegion.RegionName, regionHandle, m_Scenes.Count); 125 thisRegion.RegionName, regionHandle, m_Scenes.Count);
@@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
132 } 132 }
133 } 133 }
134 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle); 134 m_log.DebugFormat("[NEIGHBOUR CONNECTOR]: region handle {0} not found", regionHandle);
135 return false; 135 return null;
136 } 136 }
137 137
138 #endregion INeighbourService 138 #endregion INeighbourService
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
index c5bc03b..c6fc2a1 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs
@@ -118,7 +118,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
118 if (!m_Enabled) 118 if (!m_Enabled)
119 return; 119 return;
120 120
121 m_MapService = scene.CommsManager.GridService;
122 m_LocalService.AddRegion(scene); 121 m_LocalService.AddRegion(scene);
123 scene.RegisterModuleInterface<INeighbourService>(this); 122 scene.RegisterModuleInterface<INeighbourService>(this);
124 } 123 }
@@ -134,16 +133,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
134 if (!m_Enabled) 133 if (!m_Enabled)
135 return; 134 return;
136 135
136 m_GridService = scene.GridService;
137
137 m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName); 138 m_log.InfoFormat("[NEIGHBOUR CONNECTOR]: Enabled remote neighbours for region {0}", scene.RegionInfo.RegionName);
138 139
139 } 140 }
140 141
141 #region INeighbourService 142 #region INeighbourService
142 143
143 public override bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 144 public override GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
144 { 145 {
145 if (m_LocalService.HelloNeighbour(regionHandle, thisRegion)) 146 GridRegion region = m_LocalService.HelloNeighbour(regionHandle, thisRegion);
146 return true; 147 if (region != null)
148 return region;
147 149
148 return base.HelloNeighbour(regionHandle, thisRegion); 150 return base.HelloNeighbour(regionHandle, thisRegion);
149 } 151 }
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 76ff6da..fdff61e 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -36,10 +36,12 @@ using OpenSim.Framework;
36using OpenSim.Framework.Capabilities; 36using OpenSim.Framework.Capabilities;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Services.Interfaces;
39using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Physics.Manager; 42using OpenSim.Region.Physics.Manager;
42using Caps=OpenSim.Framework.Capabilities.Caps; 43using Caps=OpenSim.Framework.Capabilities.Caps;
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43 45
44namespace OpenSim.Region.CoreModules.World.Land 46namespace OpenSim.Region.CoreModules.World.Land
45{ 47{
@@ -1301,7 +1303,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1301 else 1303 else
1302 { 1304 {
1303 // a parcel request for a parcel in another region. Ask the grid about the region 1305 // a parcel request for a parcel in another region. Ask the grid about the region
1304 RegionInfo info = m_scene.CommsManager.GridService.RequestNeighbourInfo(regionID); 1306 GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID);
1305 if (info != null) 1307 if (info != null)
1306 parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y); 1308 parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
1307 } 1309 }
@@ -1359,9 +1361,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1359 } 1361 }
1360 else 1362 else
1361 { 1363 {
1362 extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle, 1364 ILandService landService = m_scene.RequestModuleInterface<ILandService>();
1363 extLandData.x, 1365 extLandData.landData = landService.GetLandData(extLandData.regionHandle,
1364 extLandData.y); 1366 extLandData.x,
1367 extLandData.y);
1365 if (extLandData.landData == null) 1368 if (extLandData.landData == null)
1366 { 1369 {
1367 // we didn't find the region/land => don't cache 1370 // we didn't find the region/land => don't cache
@@ -1373,20 +1376,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1373 1376
1374 if (data != null) // if we found some data, send it 1377 if (data != null) // if we found some data, send it
1375 { 1378 {
1376 RegionInfo info; 1379 GridRegion info;
1377 if (data.regionHandle == m_scene.RegionInfo.RegionHandle) 1380 if (data.regionHandle == m_scene.RegionInfo.RegionHandle)
1378 { 1381 {
1379 info = m_scene.RegionInfo; 1382 info = new GridRegion(m_scene.RegionInfo);
1380 } 1383 }
1381 else 1384 else
1382 { 1385 {
1383 // most likely still cached from building the extLandData entry 1386 // most likely still cached from building the extLandData entry
1384 info = m_scene.CommsManager.GridService.RequestNeighbourInfo(data.regionHandle); 1387 uint x = 0, y = 0;
1388 Utils.LongToUInts(data.regionHandle, out x, out y);
1389 info = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
1385 } 1390 }
1386 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. 1391 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
1387 m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", 1392 m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...",
1388 data.landData.Name, data.regionHandle); 1393 data.landData.Name, data.regionHandle);
1389 remoteClient.SendParcelInfo(info, data.landData, parcelID, data.x, data.y); 1394 // HACK for now
1395 RegionInfo r = new RegionInfo();
1396 r.RegionName = info.RegionName;
1397 r.RegionLocX = (uint)info.RegionLocX;
1398 r.RegionLocY = (uint)info.RegionLocY;
1399 remoteClient.SendParcelInfo(r, data.landData, parcelID, data.x, data.y);
1390 } 1400 }
1391 else 1401 else
1392 m_log.Debug("[LAND] got no parcelinfo; not sending"); 1402 m_log.Debug("[LAND] got no parcelinfo; not sending");
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 4783b35..436f332 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -33,6 +33,8 @@ using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Region.Framework.Scenes.Hypergrid; 35using OpenSim.Region.Framework.Scenes.Hypergrid;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 38
37namespace OpenSim.Region.CoreModules.World.WorldMap 39namespace OpenSim.Region.CoreModules.World.WorldMap
38{ 40{
@@ -92,13 +94,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
92 } 94 }
93 95
94 // try to fetch from GridServer 96 // try to fetch from GridServer
95 List<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20); 97 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(UUID.Zero, mapName, 20);
96 if (regionInfos == null) 98 if (regionInfos == null)
97 { 99 {
98 m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); 100 m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
99 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region 101 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
100 regionInfos = new List<RegionInfo>(); 102 regionInfos = new List<GridRegion>();
101 RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); 103 GridRegion info = m_scene.GridService.GetRegionByName(UUID.Zero, mapName);
102 if (info != null) regionInfos.Add(info); 104 if (info != null) regionInfos.Add(info);
103 } 105 }
104 106
@@ -109,11 +111,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
109 if (mapName.Contains(".") && mapName.Contains(":")) 111 if (mapName.Contains(".") && mapName.Contains(":"))
110 { 112 {
111 // It probably is a domain name. Try to link to it. 113 // It probably is a domain name. Try to link to it.
112 RegionInfo regInfo; 114 GridRegion regInfo;
113 Scene cScene = GetClientScene(remoteClient); 115 Scene cScene = GetClientScene(remoteClient);
114 regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName); 116 IHyperlinkService hyperService = cScene.RequestModuleInterface<IHyperlinkService>();
115 if (regInfo != null) 117 if (hyperService != null)
116 regionInfos.Add(regInfo); 118 {
119 regInfo = hyperService.TryLinkRegion(remoteClient, mapName);
120 if (regInfo != null)
121 regionInfos.Add(regInfo);
122 }
117 } 123 }
118 } 124 }
119 125
@@ -122,17 +128,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
122 MapBlockData data; 128 MapBlockData data;
123 if (regionInfos.Count > 0) 129 if (regionInfos.Count > 0)
124 { 130 {
125 foreach (RegionInfo info in regionInfos) 131 foreach (GridRegion info in regionInfos)
126 { 132 {
127 data = new MapBlockData(); 133 data = new MapBlockData();
128 data.Agents = 0; 134 data.Agents = 0;
129 data.Access = info.AccessLevel; 135 data.Access = info.Access;
130 data.MapImageId = info.RegionSettings.TerrainImageID; 136 data.MapImageId = info.TerrainImage;
131 data.Name = info.RegionName; 137 data.Name = info.RegionName;
132 data.RegionFlags = 0; // TODO not used? 138 data.RegionFlags = 0; // TODO not used?
133 data.WaterHeight = 0; // not used 139 data.WaterHeight = 0; // not used
134 data.X = (ushort)info.RegionLocX; 140 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
135 data.Y = (ushort)info.RegionLocY; 141 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
136 blocks.Add(data); 142 blocks.Add(data);
137 } 143 }
138 } 144 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 1f25f28..05ed70a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -48,6 +48,7 @@ using OpenSim.Region.Framework.Scenes;
48using Caps=OpenSim.Framework.Capabilities.Caps; 48using Caps=OpenSim.Framework.Capabilities.Caps;
49using OSDArray=OpenMetaverse.StructuredData.OSDArray; 49using OSDArray=OpenMetaverse.StructuredData.OSDArray;
50using OSDMap=OpenMetaverse.StructuredData.OSDMap; 50using OSDMap=OpenMetaverse.StructuredData.OSDMap;
51using GridRegion = OpenSim.Services.Interfaces.GridRegion;
51 52
52namespace OpenSim.Region.CoreModules.World.WorldMap 53namespace OpenSim.Region.CoreModules.World.WorldMap
53{ 54{
@@ -232,10 +233,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
232 } 233 }
233 if (lookup) 234 if (lookup)
234 { 235 {
235 List<MapBlockData> mapBlocks; 236 List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
236 237
237 mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8); 238 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
238 avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0); 239 (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize,
240 (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize,
241 (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize,
242 (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize);
243 foreach (GridRegion r in regions)
244 {
245 MapBlockData block = new MapBlockData();
246 MapBlockFromGridRegion(block, r);
247 mapBlocks.Add(block);
248 }
249 avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
239 250
240 lock (cachedMapBlocks) 251 lock (cachedMapBlocks)
241 cachedMapBlocks = mapBlocks; 252 cachedMapBlocks = mapBlocks;
@@ -579,7 +590,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
579 } 590 }
580 if (httpserver.Length == 0) 591 if (httpserver.Length == 0)
581 { 592 {
582 RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle); 593 uint x = 0, y = 0;
594 Utils.LongToUInts(regionhandle, out x, out y);
595 GridRegion mreg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
583 596
584 if (mreg != null) 597 if (mreg != null)
585 { 598 {
@@ -719,15 +732,25 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
719 { 732 {
720 List<MapBlockData> response = new List<MapBlockData>(); 733 List<MapBlockData> response = new List<MapBlockData>();
721 734
722 // this should return one mapblock at most. But make sure: Look whether the one we requested is in there 735 // this should return one mapblock at most.
723 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 736 // (diva note: why?? in that case we should GetRegionByPosition)
724 if (mapBlocks != null) 737 // But make sure: Look whether the one we requested is in there
738 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
739 minX * (int)Constants.RegionSize,
740 maxX * (int)Constants.RegionSize,
741 minY * (int)Constants.RegionSize,
742 maxY * (int)Constants.RegionSize);
743
744 if (regions != null)
725 { 745 {
726 foreach (MapBlockData block in mapBlocks) 746 foreach (GridRegion r in regions)
727 { 747 {
728 if (block.X == minX && block.Y == minY) 748 if ((r.RegionLocX == minX * (int)Constants.RegionSize) &&
749 (r.RegionLocY == minY * (int)Constants.RegionSize))
729 { 750 {
730 // found it => add it to response 751 // found it => add it to response
752 MapBlockData block = new MapBlockData();
753 MapBlockFromGridRegion(block, r);
731 response.Add(block); 754 response.Add(block);
732 break; 755 break;
733 } 756 }
@@ -754,10 +777,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
754 777
755 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 778 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
756 { 779 {
757 List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4); 780 List<MapBlockData> mapBlocks = new List<MapBlockData>();
781 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
782 (minX - 4) * (int)Constants.RegionSize,
783 (maxX + 4) * (int)Constants.RegionSize,
784 (minY - 4) * (int)Constants.RegionSize,
785 (maxY + 4) * (int)Constants.RegionSize);
786 foreach (GridRegion r in regions)
787 {
788 MapBlockData block = new MapBlockData();
789 MapBlockFromGridRegion(block, r);
790 mapBlocks.Add(block);
791 }
758 remoteClient.SendMapBlock(mapBlocks, flag); 792 remoteClient.SendMapBlock(mapBlocks, flag);
759 } 793 }
760 794
795 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)
796 {
797 block.Access = r.Access;
798 block.MapImageId = r.TerrainImage;
799 block.Name = r.RegionName;
800 block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
801 block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
802 }
803
761 public Hashtable OnHTTPGetMapImage(Hashtable keysvals) 804 public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
762 { 805 {
763 m_log.Debug("[WORLD MAP]: Sending map image jpeg"); 806 m_log.Debug("[WORLD MAP]: Sending map image jpeg");
@@ -874,31 +917,34 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
874 m_log.InfoFormat( 917 m_log.InfoFormat(
875 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); 918 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
876 919
877 List<MapBlockData> mapBlocks = 920 List<MapBlockData> mapBlocks = new List<MapBlockData>();
878 m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( 921 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
879 (int)(m_scene.RegionInfo.RegionLocX - 9), 922 (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize,
880 (int)(m_scene.RegionInfo.RegionLocY - 9), 923 (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize,
881 (int)(m_scene.RegionInfo.RegionLocX + 9), 924 (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize,
882 (int)(m_scene.RegionInfo.RegionLocY + 9)); 925 (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize);
883 List<AssetBase> textures = new List<AssetBase>(); 926 List<AssetBase> textures = new List<AssetBase>();
884 List<Image> bitImages = new List<Image>(); 927 List<Image> bitImages = new List<Image>();
885 928
886 foreach (MapBlockData mapBlock in mapBlocks) 929 foreach (GridRegion r in regions)
887 { 930 {
931 MapBlockData mapBlock = new MapBlockData();
932 MapBlockFromGridRegion(mapBlock, r);
888 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 933 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
889 934
890 if (texAsset != null) 935 if (texAsset != null)
891 { 936 {
892 textures.Add(texAsset); 937 textures.Add(texAsset);
893 } 938 }
894 else 939 //else
895 { 940 //{
896 texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 941 // // WHAT?!? This doesn't seem right. Commenting (diva)
897 if (texAsset != null) 942 // texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
898 { 943 // if (texAsset != null)
899 textures.Add(texAsset); 944 // {
900 } 945 // textures.Add(texAsset);
901 } 946 // }
947 //}
902 } 948 }
903 949
904 foreach (AssetBase asset in textures) 950 foreach (AssetBase asset in textures)
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 287d8d9..7424b24 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -32,6 +32,7 @@ using OpenSim.Framework;
32using OpenSim.Framework.Client; 32using OpenSim.Framework.Client;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using Caps=OpenSim.Framework.Capabilities.Caps; 34using Caps=OpenSim.Framework.Capabilities.Caps;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -305,6 +306,9 @@ namespace OpenSim.Region.Framework.Scenes
305 public delegate void Attach(uint localID, UUID itemID, UUID avatarID); 306 public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
306 public event Attach OnAttach; 307 public event Attach OnAttach;
307 308
309 public delegate void RegionUp(GridRegion region);
310 public event RegionUp OnRegionUp;
311
308 public class MoneyTransferArgs : EventArgs 312 public class MoneyTransferArgs : EventArgs
309 { 313 {
310 public UUID sender; 314 public UUID sender;
@@ -446,6 +450,7 @@ namespace OpenSim.Region.Framework.Scenes
446 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null; 450 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
447 451
448 private Attach handlerOnAttach = null; 452 private Attach handlerOnAttach = null;
453 private RegionUp handlerOnRegionUp = null;
449 454
450 public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) 455 public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
451 { 456 {
@@ -1035,5 +1040,13 @@ namespace OpenSim.Region.Framework.Scenes
1035 if (handlerSetRootAgentScene != null) 1040 if (handlerSetRootAgentScene != null)
1036 handlerSetRootAgentScene(agentID, scene); 1041 handlerSetRootAgentScene(agentID, scene);
1037 } 1042 }
1043
1044 public void TriggerOnRegionUp(GridRegion otherRegion)
1045 {
1046 handlerOnRegionUp = OnRegionUp;
1047 if (handlerOnRegionUp != null)
1048 handlerOnRegionUp(otherRegion);
1049 }
1050
1038 } 1051 }
1039} 1052}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 62efd60..b6fa41d 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients; 36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization; 37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Services.Interfaces;
38 39
39//using HyperGrid.Framework; 40//using HyperGrid.Framework;
40//using OpenSim.Region.Communications.Hypergrid; 41//using OpenSim.Region.Communications.Hypergrid;
@@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
50// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); 51// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
51 52
52 private Scene m_scene; 53 private Scene m_scene;
54
55 private IHyperlinkService m_hyper;
56 IHyperlinkService HyperlinkService
57 {
58 get
59 {
60 if (m_hyper == null)
61 m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>();
62 return m_hyper;
63 }
64 }
65
53 #endregion 66 #endregion
54 67
55 #region Constructor 68 #region Constructor
@@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
79// return null; 92// return null;
80// } 93// }
81 94
82 private bool IsLocalUser(UUID userID)
83 {
84 CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
85
86 if (uinfo != null)
87 {
88 if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
89 {
90 m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
91 return true;
92 }
93 }
94
95 m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
96 return false;
97 }
98 95
99 public AssetBase FetchAsset(string url, UUID assetID) 96 public AssetBase FetchAsset(string url, UUID assetID)
100 { 97 {
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
170 167
171 public void Get(UUID assetID, UUID ownerID) 168 public void Get(UUID assetID, UUID ownerID)
172 { 169 {
173 if (!IsLocalUser(ownerID)) 170 if (!HyperlinkService.IsLocalUser(ownerID))
174 { 171 {
175 // Get the item from the remote asset server onto the local AssetCache 172 // Get the item from the remote asset server onto the local AssetCache
176 // and place an entry in m_assetMap 173 // and place an entry in m_assetMap
@@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
228 225
229 public void Post(UUID assetID, UUID ownerID) 226 public void Post(UUID assetID, UUID ownerID)
230 { 227 {
231 if (!IsLocalUser(ownerID)) 228 if (!HyperlinkService.IsLocalUser(ownerID))
232 { 229 {
233 // Post the item from the local AssetCache onto the remote asset server 230 // Post the item from the local AssetCache onto the remote asset server
234 // and place an entry in m_assetMap 231 // and place an entry in m_assetMap
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
deleted file mode 100644
index a576feb..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
+++ /dev/null
@@ -1,232 +0,0 @@
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
28using System;
29using System.Net;
30using System.Reflection;
31using log4net;
32using OpenMetaverse;
33using OpenSim.Framework;
34
35namespace OpenSim.Region.Framework.Scenes.Hypergrid
36{
37 public class HGHyperlink
38 {
39 private static readonly ILog m_log =
40 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 private static Random random = new Random();
42
43 public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
44 {
45 string host = "127.0.0.1";
46 string portstr;
47 string regionName = "";
48 uint port = 9000;
49 string[] parts = mapName.Split(new char[] { ':' });
50 if (parts.Length >= 1)
51 {
52 host = parts[0];
53 }
54 if (parts.Length >= 2)
55 {
56 portstr = parts[1];
57 if (!UInt32.TryParse(portstr, out port))
58 regionName = parts[1];
59 }
60 // always take the last one
61 if (parts.Length >= 3)
62 {
63 regionName = parts[2];
64 }
65
66 // Sanity check. Don't ever link to this sim.
67 IPAddress ipaddr = null;
68 try
69 {
70 ipaddr = Util.GetHostFromDNS(host);
71 }
72 catch { }
73
74 if ((ipaddr != null) &&
75 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
76 {
77 RegionInfo regInfo;
78 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
79 if (success)
80 {
81 regInfo.RegionName = mapName;
82 return regInfo;
83 }
84 }
85
86 return null;
87 }
88
89 public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
90 {
91 uint xloc = (uint)(random.Next(0, Int16.MaxValue));
92 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
93 }
94
95 public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
96 string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
97 {
98 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
99
100 regInfo = new RegionInfo();
101 regInfo.RegionName = externalRegionName;
102 regInfo.HttpPort = externalPort;
103 regInfo.ExternalHostName = externalHostName;
104 regInfo.RegionLocX = xloc;
105 regInfo.RegionLocY = yloc;
106
107 try
108 {
109 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
110 }
111 catch (Exception e)
112 {
113 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
114 return false;
115 }
116 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
117
118 // Finally, link it
119 try
120 {
121 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
122 }
123 catch (Exception e)
124 {
125 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
126 return false;
127 }
128
129 uint x, y;
130 if (!Check4096(m_scene, regInfo, out x, out y))
131 {
132 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
133 if (client != null)
134 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
135 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
136 return false;
137 }
138
139 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
140 {
141 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
142 if (client != null)
143 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
144 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
145 return false;
146 }
147
148 m_log.Debug("[HGrid]: link region succeeded");
149 return true;
150 }
151
152 public static bool TryUnlinkRegion(Scene m_scene, string mapName)
153 {
154 RegionInfo regInfo = null;
155 if (mapName.Contains(":"))
156 {
157 string host = "127.0.0.1";
158 //string portstr;
159 //string regionName = "";
160 uint port = 9000;
161 string[] parts = mapName.Split(new char[] { ':' });
162 if (parts.Length >= 1)
163 {
164 host = parts[0];
165 }
166// if (parts.Length >= 2)
167// {
168// portstr = parts[1];
169// if (!UInt32.TryParse(portstr, out port))
170// regionName = parts[1];
171// }
172 // always take the last one
173// if (parts.Length >= 3)
174// {
175// regionName = parts[2];
176// }
177 regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port);
178 }
179 else
180 {
181 regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName);
182 }
183 if (regInfo != null)
184 {
185 return m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
186 }
187 else
188 {
189 m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
190 return false;
191 }
192 }
193
194 /// <summary>
195 /// Cope with this viewer limitation.
196 /// </summary>
197 /// <param name="regInfo"></param>
198 /// <returns></returns>
199 public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
200 {
201 ulong realHandle;
202 if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
203 {
204 Utils.LongToUInts(realHandle, out x, out y);
205 x = x / Constants.RegionSize;
206 y = y / Constants.RegionSize;
207
208 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
209 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
210 {
211 return false;
212 }
213 return true;
214 }
215 else
216 {
217 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
218 m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
219 x = y = 0;
220 return false;
221 }
222 }
223
224 public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
225 {
226 if ((thisx == x) && (thisy == y))
227 return false;
228 return true;
229 }
230
231 }
232}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
index bf55df7..b1981b6 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
@@ -29,6 +29,7 @@ using OpenMetaverse;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache; 30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
32 33
33namespace OpenSim.Region.Framework.Scenes.Hypergrid 34namespace OpenSim.Region.Framework.Scenes.Hypergrid
34{ 35{
@@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
50 51
51 if (UserProfile != null) 52 if (UserProfile != null)
52 { 53 {
53 RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); 54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
54 //if (regionInfo != null) 55 //if (regionInfo != null)
55 //{ 56 //{
56 // UserProfile.HomeRegionID = regionInfo.RegionID; 57 // UserProfile.HomeRegionID = regionInfo.RegionID;
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index efc644d..1217f9b 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -38,6 +38,8 @@ using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41 43
42namespace OpenSim.Region.Framework.Scenes.Hypergrid 44namespace OpenSim.Region.Framework.Scenes.Hypergrid
43{ 45{
@@ -45,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
45 { 47 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 49
48 public readonly IHyperlink m_hg; 50 private IHyperlinkService m_hg;
51 IHyperlinkService HyperlinkService
52 {
53 get
54 {
55 if (m_hg == null)
56 m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
57 return m_hg;
58 }
59 }
49 60
50 public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) 61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
51 { 62 {
52 m_hg = hg;
53 } 63 }
54 64
55 65
@@ -112,7 +122,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
112 } 122 }
113 else 123 else
114 { 124 {
115 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 125 uint x = 0, y = 0;
126 Utils.LongToUInts(regionHandle, out x, out y);
127 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
128
116 if (reg != null) 129 if (reg != null)
117 { 130 {
118 131
@@ -125,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
125 /// Hypergrid mod start 138 /// Hypergrid mod start
126 /// 139 ///
127 /// 140 ///
128 bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); 141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
129 bool isHomeUser = true; 142 bool isHomeUser = true;
130 ulong realHandle = regionHandle; 143 ulong realHandle = regionHandle;
131 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); 144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
132 if (uinfo != null) 145 if (uinfo != null)
133 { 146 {
134 isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile); 147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
135 realHandle = m_hg.FindRegionHandle(regionHandle); 148 realHandle = m_hg.FindRegionHandle(regionHandle);
136 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); 149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
137 } 150 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8478a2..bb47ff4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization;
49using OpenSim.Region.Physics.Manager; 49using OpenSim.Region.Physics.Manager;
50using Timer=System.Timers.Timer; 50using Timer=System.Timers.Timer;
51using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 51using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion;
52 53
53namespace OpenSim.Region.Framework.Scenes 54namespace OpenSim.Region.Framework.Scenes
54{ 55{
@@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes
193 } 194 }
194 } 195 }
195 196
197 protected IGridService m_GridService = null;
198
199 public IGridService GridService
200 {
201 get
202 {
203 if (m_GridService == null)
204 {
205 m_GridService = RequestModuleInterface<IGridService>();
206
207 if (m_GridService == null)
208 {
209 throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
210 }
211 }
212
213 return m_GridService;
214 }
215 }
216
196 protected IXMLRPC m_xmlrpcModule; 217 protected IXMLRPC m_xmlrpcModule;
197 protected IWorldComm m_worldCommModule; 218 protected IWorldComm m_worldCommModule;
198 protected IAvatarFactory m_AvatarFactory; 219 protected IAvatarFactory m_AvatarFactory;
@@ -566,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
566 } 587 }
567 588
568 /// <summary> 589 /// <summary>
569 /// Another region is up. Gets called from Grid Comms: 590 /// Another region is up.
570 /// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
571 /// We have to tell all our ScenePresences about it, and add it to the
572 /// neighbor list.
573 /// 591 ///
574 /// We only add it to the neighbor list if it's within 1 region from here. 592 /// We only add it to the neighbor list if it's within 1 region from here.
575 /// Agents may have draw distance values that cross two regions though, so 593 /// Agents may have draw distance values that cross two regions though, so
@@ -578,47 +596,30 @@ namespace OpenSim.Region.Framework.Scenes
578 /// </summary> 596 /// </summary>
579 /// <param name="otherRegion">RegionInfo handle for the new region.</param> 597 /// <param name="otherRegion">RegionInfo handle for the new region.</param>
580 /// <returns>True after all operations complete, throws exceptions otherwise.</returns> 598 /// <returns>True after all operations complete, throws exceptions otherwise.</returns>
581 public override bool OtherRegionUp(RegionInfo otherRegion) 599 public override void OtherRegionUp(GridRegion otherRegion)
582 { 600 {
583 m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 601 uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
602 uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
603 m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
604 RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
584 605
585 if (RegionInfo.RegionHandle != otherRegion.RegionHandle) 606 if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
586 { 607 {
587 for (int i = 0; i < m_neighbours.Count; i++)
588 {
589 // The purpose of this loop is to re-update the known neighbors
590 // when another region comes up on top of another one.
591 // The latest region in that location ends up in the
592 // 'known neighbors list'
593 // Additionally, the commFailTF property gets reset to false.
594 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
595 {
596 lock (m_neighbours)
597 {
598 m_neighbours[i] = otherRegion;
599
600 }
601 }
602 }
603
604 // If the value isn't in the neighbours, add it.
605 // If the RegionInfo isn't exact but is for the same XY World location,
606 // then the above loop will fix that.
607
608 if (!(CheckNeighborRegion(otherRegion)))
609 {
610 lock (m_neighbours)
611 {
612 m_neighbours.Add(otherRegion);
613 //m_log.Info("[UP]: " + otherRegion.RegionHandle.ToString());
614 }
615 }
616 608
617 // If these are cast to INT because long + negative values + abs returns invalid data 609 // If these are cast to INT because long + negative values + abs returns invalid data
618 int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); 610 int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
619 int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); 611 int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
620 if (resultX <= 1 && resultY <= 1) 612 if (resultX <= 1 && resultY <= 1)
621 { 613 {
614 // Let the grid service module know, so this can be cached
615 m_eventManager.TriggerOnRegionUp(otherRegion);
616
617 RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName);
618 regInfo.RegionID = otherRegion.RegionID;
619 regInfo.RegionName = otherRegion.RegionName;
620 regInfo.ScopeID = otherRegion.ScopeID;
621 regInfo.ExternalHostName = otherRegion.ExternalHostName;
622
622 try 623 try
623 { 624 {
624 ForEachScenePresence(delegate(ScenePresence agent) 625 ForEachScenePresence(delegate(ScenePresence agent)
@@ -632,7 +633,7 @@ namespace OpenSim.Region.Framework.Scenes
632 List<ulong> old = new List<ulong>(); 633 List<ulong> old = new List<ulong>();
633 old.Add(otherRegion.RegionHandle); 634 old.Add(otherRegion.RegionHandle);
634 agent.DropOldNeighbours(old); 635 agent.DropOldNeighbours(old);
635 InformClientOfNeighbor(agent, otherRegion); 636 InformClientOfNeighbor(agent, regInfo);
636 } 637 }
637 } 638 }
638 ); 639 );
@@ -643,6 +644,7 @@ namespace OpenSim.Region.Framework.Scenes
643 // This shouldn't happen too often anymore. 644 // This shouldn't happen too often anymore.
644 m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception"); 645 m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception");
645 } 646 }
647
646 } 648 }
647 else 649 else
648 { 650 {
@@ -651,7 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
651 otherRegion.RegionLocY.ToString() + ")"); 653 otherRegion.RegionLocY.ToString() + ")");
652 } 654 }
653 } 655 }
654 return true;
655 } 656 }
656 657
657 public void AddNeighborRegion(RegionInfo region) 658 public void AddNeighborRegion(RegionInfo region)
@@ -683,9 +684,10 @@ namespace OpenSim.Region.Framework.Scenes
683 } 684 }
684 685
685 // Alias IncomingHelloNeighbour OtherRegionUp, for now 686 // Alias IncomingHelloNeighbour OtherRegionUp, for now
686 public bool IncomingHelloNeighbour(RegionInfo neighbour) 687 public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
687 { 688 {
688 return OtherRegionUp(neighbour); 689 OtherRegionUp(new GridRegion(neighbour));
690 return new GridRegion(RegionInfo);
689 } 691 }
690 692
691 /// <summary> 693 /// <summary>
@@ -1336,24 +1338,31 @@ namespace OpenSim.Region.Framework.Scenes
1336 RegisterCommsEvents(); 1338 RegisterCommsEvents();
1337 1339
1338 // These two 'commands' *must be* next to each other or sim rebooting fails. 1340 // These two 'commands' *must be* next to each other or sim rebooting fails.
1339 m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); 1341 //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
1342
1343 GridRegion region = new GridRegion(RegionInfo);
1344 bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1345 if (!success)
1346 throw new Exception("Can't register with grid");
1347
1348 m_sceneGridService.SetScene(this);
1340 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1349 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1341 1350
1342 Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings(); 1351 //Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
1343 1352
1344 if (dGridSettings.ContainsKey("allow_forceful_banlines")) 1353 //if (dGridSettings.ContainsKey("allow_forceful_banlines"))
1345 { 1354 //{
1346 if (dGridSettings["allow_forceful_banlines"] != "TRUE") 1355 // if (dGridSettings["allow_forceful_banlines"] != "TRUE")
1347 { 1356 // {
1348 m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); 1357 // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
1349 EventManager.TriggerSetAllowForcefulBan(false); 1358 // EventManager.TriggerSetAllowForcefulBan(false);
1350 } 1359 // }
1351 else 1360 // else
1352 { 1361 // {
1353 m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); 1362 // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
1354 EventManager.TriggerSetAllowForcefulBan(true); 1363 // EventManager.TriggerSetAllowForcefulBan(true);
1355 } 1364 // }
1356 } 1365 //}
1357 } 1366 }
1358 1367
1359 /// <summary> 1368 /// <summary>
@@ -2717,10 +2726,12 @@ namespace OpenSim.Region.Framework.Scenes
2717 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2726 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
2718 if (UserProfile != null) 2727 if (UserProfile != null)
2719 { 2728 {
2720 RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID); 2729 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
2721 if (regionInfo == null) 2730 if (regionInfo == null)
2722 { 2731 {
2723 regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); 2732 uint x = 0, y = 0;
2733 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2734 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2724 if (regionInfo != null) // home region can be away temporarily, too 2735 if (regionInfo != null) // home region can be away temporarily, too
2725 { 2736 {
2726 UserProfile.HomeRegionID = regionInfo.RegionID; 2737 UserProfile.HomeRegionID = regionInfo.RegionID;
@@ -3074,7 +3085,7 @@ namespace OpenSim.Region.Framework.Scenes
3074 m_sceneGridService.OnExpectUser += HandleNewUserConnection; 3085 m_sceneGridService.OnExpectUser += HandleNewUserConnection;
3075 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; 3086 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
3076 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; 3087 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
3077 m_sceneGridService.OnRegionUp += OtherRegionUp; 3088 //m_eventManager.OnRegionUp += OtherRegionUp;
3078 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3089 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3079 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; 3090 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
3080 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3091 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@@ -3102,7 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
3102 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3113 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3103 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; 3114 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
3104 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3115 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3105 m_sceneGridService.OnRegionUp -= OtherRegionUp; 3116 //m_eventManager.OnRegionUp -= OtherRegionUp;
3106 m_sceneGridService.OnExpectUser -= HandleNewUserConnection; 3117 m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
3107 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; 3118 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
3108 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3119 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
@@ -3111,7 +3122,11 @@ namespace OpenSim.Region.Framework.Scenes
3111 if (m_interregionCommsIn != null) 3122 if (m_interregionCommsIn != null)
3112 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3123 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3113 3124
3125 // this does nothing; should be removed
3114 m_sceneGridService.Close(); 3126 m_sceneGridService.Close();
3127
3128 if (!GridService.DeregisterRegion(m_regInfo.RegionID))
3129 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
3115 } 3130 }
3116 3131
3117 /// <summary> 3132 /// <summary>
@@ -3557,30 +3572,6 @@ namespace OpenSim.Region.Framework.Scenes
3557 } 3572 }
3558 3573
3559 /// <summary> 3574 /// <summary>
3560 /// Requests information about this region from gridcomms
3561 /// </summary>
3562 /// <param name="regionHandle"></param>
3563 /// <returns></returns>
3564 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
3565 {
3566 return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
3567 }
3568
3569 /// <summary>
3570 /// Requests textures for map from minimum region to maximum region in world cordinates
3571 /// </summary>
3572 /// <param name="remoteClient"></param>
3573 /// <param name="minX"></param>
3574 /// <param name="minY"></param>
3575 /// <param name="maxX"></param>
3576 /// <param name="maxY"></param>
3577 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
3578 {
3579 m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
3580 m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
3581 }
3582
3583 /// <summary>
3584 /// Tries to teleport agent to other region. 3575 /// Tries to teleport agent to other region.
3585 /// </summary> 3576 /// </summary>
3586 /// <param name="remoteClient"></param> 3577 /// <param name="remoteClient"></param>
@@ -3591,7 +3582,7 @@ namespace OpenSim.Region.Framework.Scenes
3591 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 3582 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
3592 Vector3 lookat, uint teleportFlags) 3583 Vector3 lookat, uint teleportFlags)
3593 { 3584 {
3594 RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName); 3585 GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
3595 if (regionInfo == null) 3586 if (regionInfo == null)
3596 { 3587 {
3597 // can't find the region: Tell viewer and abort 3588 // can't find the region: Tell viewer and abort
@@ -3680,7 +3671,7 @@ namespace OpenSim.Region.Framework.Scenes
3680 /// <param name="position"></param> 3671 /// <param name="position"></param>
3681 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position) 3672 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position)
3682 { 3673 {
3683 RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID); 3674 GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID);
3684 3675
3685 if (info == null) 3676 if (info == null)
3686 { 3677 {
@@ -3864,10 +3855,6 @@ namespace OpenSim.Region.Framework.Scenes
3864 return LandChannel.GetLandObject((int)x, (int)y).landData; 3855 return LandChannel.GetLandObject((int)x, (int)y).landData;
3865 } 3856 }
3866 3857
3867 public RegionInfo RequestClosestRegion(string name)
3868 {
3869 return m_sceneGridService.RequestClosestRegion(name);
3870 }
3871 3858
3872 #endregion 3859 #endregion
3873 3860
@@ -4178,14 +4165,18 @@ namespace OpenSim.Region.Framework.Scenes
4178 4165
4179 public void RegionHandleRequest(IClientAPI client, UUID regionID) 4166 public void RegionHandleRequest(IClientAPI client, UUID regionID)
4180 { 4167 {
4181 RegionInfo info; 4168 ulong handle = 0;
4182 if (regionID == RegionInfo.RegionID) 4169 if (regionID == RegionInfo.RegionID)
4183 info = RegionInfo; 4170 handle = RegionInfo.RegionHandle;
4184 else 4171 else
4185 info = CommsManager.GridService.RequestNeighbourInfo(regionID); 4172 {
4173 GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
4174 if (r != null)
4175 handle = r.RegionHandle;
4176 }
4186 4177
4187 if (info != null) 4178 if (handle != 0)
4188 client.SendRegionHandle(regionID, info.RegionHandle); 4179 client.SendRegionHandle(regionID, handle);
4189 } 4180 }
4190 4181
4191 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY) 4182 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 2a82237..2af98cc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
41{ 42{
@@ -227,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
227 return false; 228 return false;
228 } 229 }
229 230
230 public abstract bool OtherRegionUp(RegionInfo thisRegion); 231 public abstract void OtherRegionUp(GridRegion otherRegion);
231 232
232 public virtual string GetSimulatorVersion() 233 public virtual string GetSimulatorVersion()
233 { 234 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 5f2333e..4a2db5e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OSD = OpenMetaverse.StructuredData.OSD; 43using OSD = OpenMetaverse.StructuredData.OSD;
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
44 45
45namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
46{ 47{
@@ -58,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes
58 protected CommunicationsManager m_commsProvider; 59 protected CommunicationsManager m_commsProvider;
59 protected IInterregionCommsOut m_interregionCommsOut; 60 protected IInterregionCommsOut m_interregionCommsOut;
60 protected RegionInfo m_regionInfo; 61 protected RegionInfo m_regionInfo;
62 protected Scene m_scene;
61 63
62 protected RegionCommsListener regionCommsHost; 64 protected RegionCommsListener regionCommsHost;
63 65
@@ -91,10 +93,10 @@ namespace OpenSim.Region.Framework.Scenes
91 /// </summary> 93 /// </summary>
92 public event PrimCrossing OnPrimCrossingIntoRegion; 94 public event PrimCrossing OnPrimCrossingIntoRegion;
93 95
94 /// <summary> 96 ///// <summary>
95 /// A New Region is up and available 97 ///// A New Region is up and available
96 /// </summary> 98 ///// </summary>
97 public event RegionUp OnRegionUp; 99 //public event RegionUp OnRegionUp;
98 100
99 /// <summary> 101 /// <summary>
100 /// We have a child agent for this avatar and we're getting a status update about it 102 /// We have a child agent for this avatar and we're getting a status update about it
@@ -117,7 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
117 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; 119 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
118 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 120 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
119 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 121 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
120 private RegionUp handlerRegionUp = null; // OnRegionUp; 122 //private RegionUp handlerRegionUp = null; // OnRegionUp;
121 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; 123 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
122 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; 124 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
123 private LogOffUser handlerLogOffUser = null; 125 private LogOffUser handlerLogOffUser = null;
@@ -131,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes
131 m_agentsInTransit = new List<UUID>(); 133 m_agentsInTransit = new List<UUID>();
132 } 134 }
133 135
136 public void SetScene(Scene s)
137 {
138 m_scene = s;
139 m_regionInfo = s.RegionInfo;
140 m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
141 }
142
134 /// <summary> 143 /// <summary>
135 /// Register a region with the grid 144 /// Register a region with the grid
136 /// </summary> 145 /// </summary>
@@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
138 /// <exception cref="System.Exception">Thrown if region registration fails.</exception> 147 /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
139 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) 148 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
140 { 149 {
141 m_interregionCommsOut = comms_out; 150 //m_interregionCommsOut = comms_out;
142 151
143 m_regionInfo = regionInfos; 152 //m_regionInfo = regionInfos;
144 m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; 153 //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
145 regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); 154 //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
146 155
147 if (regionCommsHost != null) 156 //if (regionCommsHost != null)
148 { 157 //{
149 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); 158 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
150 159
151 regionCommsHost.debugRegionName = regionInfos.RegionName; 160 // regionCommsHost.debugRegionName = regionInfos.RegionName;
152 regionCommsHost.OnExpectPrim += IncomingPrimCrossing; 161 // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
153 regionCommsHost.OnExpectUser += NewUserConnection; 162 // regionCommsHost.OnExpectUser += NewUserConnection;
154 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; 163 // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
155 regionCommsHost.OnCloseAgentConnection += CloseConnection; 164 // regionCommsHost.OnCloseAgentConnection += CloseConnection;
156 regionCommsHost.OnRegionUp += newRegionUp; 165 // regionCommsHost.OnRegionUp += newRegionUp;
157 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; 166 // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
158 regionCommsHost.OnLogOffUser += GridLogOffUser; 167 // regionCommsHost.OnLogOffUser += GridLogOffUser;
159 regionCommsHost.OnGetLandData += FetchLandData; 168 // regionCommsHost.OnGetLandData += FetchLandData;
160 } 169 //}
161 else 170 //else
162 { 171 //{
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); 172 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
164 } 173 //}
165 }
166
167 /// <summary>
168 /// Returns a region with the name closest to string provided
169 /// </summary>
170 /// <param name="name">Partial Region Name for matching</param>
171 /// <returns>Region Information for the region</returns>
172 public RegionInfo RequestClosestRegion(string name)
173 {
174 return m_commsProvider.GridService.RequestClosestRegion(name);
175 } 174 }
176 175
177 /// <summary> 176 /// <summary>
@@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
180 /// </summary> 179 /// </summary>
181 public void Close() 180 public void Close()
182 { 181 {
183 if (regionCommsHost != null) 182
184 { 183 //if (regionCommsHost != null)
185 regionCommsHost.OnLogOffUser -= GridLogOffUser; 184 //{
186 regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; 185 // regionCommsHost.OnLogOffUser -= GridLogOffUser;
187 regionCommsHost.OnRegionUp -= newRegionUp; 186 // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
188 regionCommsHost.OnExpectUser -= NewUserConnection; 187 // regionCommsHost.OnRegionUp -= newRegionUp;
189 regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; 188 // regionCommsHost.OnExpectUser -= NewUserConnection;
190 regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; 189 // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
191 regionCommsHost.OnCloseAgentConnection -= CloseConnection; 190 // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
192 regionCommsHost.OnGetLandData -= FetchLandData; 191 // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
192 // regionCommsHost.OnGetLandData -= FetchLandData;
193 193
194 try 194 // try
195 { 195 // {
196 m_commsProvider.GridService.DeregisterRegion(m_regionInfo); 196 // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
197 } 197 // }
198 catch (Exception e) 198 // catch (Exception e)
199 { 199 // {
200 m_log.ErrorFormat( 200 // m_log.ErrorFormat(
201 "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", 201 // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
202 m_regionInfo.RegionName, e); 202 // m_regionInfo.RegionName, e);
203 } 203 // }
204 204
205 regionCommsHost = null; 205 // regionCommsHost = null;
206 } 206 //}
207 } 207 }
208 208
209 #region CommsManager Event handlers 209 #region CommsManager Event handlers
@@ -239,22 +239,6 @@ namespace OpenSim.Region.Framework.Scenes
239 } 239 }
240 240
241 /// <summary> 241 /// <summary>
242 /// A New Region is now available. Inform the scene that there is a new region available.
243 /// </summary>
244 /// <param name="region">Information about the new region that is available</param>
245 /// <returns>True if the event was handled</returns>
246 protected bool newRegionUp(RegionInfo region)
247 {
248 handlerRegionUp = OnRegionUp;
249 if (handlerRegionUp != null)
250 {
251 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
252 handlerRegionUp(region);
253 }
254 return true;
255 }
256
257 /// <summary>
258 /// Inform the scene that we've got an update about a child agent that we have 242 /// Inform the scene that we've got an update about a child agent that we have
259 /// </summary> 243 /// </summary>
260 /// <param name="cAgentData"></param> 244 /// <param name="cAgentData"></param>
@@ -337,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes
337 #region Inform Client of Neighbours 321 #region Inform Client of Neighbours
338 322
339 private delegate void InformClientOfNeighbourDelegate( 323 private delegate void InformClientOfNeighbourDelegate(
340 ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent); 324 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
341 325
342 private void InformClientOfNeighbourCompleted(IAsyncResult iar) 326 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
343 { 327 {
@@ -355,7 +339,7 @@ namespace OpenSim.Region.Framework.Scenes
355 /// <param name="a"></param> 339 /// <param name="a"></param>
356 /// <param name="regionHandle"></param> 340 /// <param name="regionHandle"></param>
357 /// <param name="endPoint"></param> 341 /// <param name="endPoint"></param>
358 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, 342 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
359 IPEndPoint endPoint, bool newAgent) 343 IPEndPoint endPoint, bool newAgent)
360 { 344 {
361 // Let's wait just a little to give time to originating regions to catch up with closing child agents 345 // Let's wait just a little to give time to originating regions to catch up with closing child agents
@@ -373,8 +357,7 @@ namespace OpenSim.Region.Framework.Scenes
373 357
374 string reason = String.Empty; 358 string reason = String.Empty;
375 359
376 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); 360
377
378 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); 361 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
379 362
380 if (regionAccepted && newAgent) 363 if (regionAccepted && newAgent)
@@ -407,17 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
407 390
408 } 391 }
409 392
410 public void RequestNeighbors(RegionInfo region) 393 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
411 {
412 // List<SimpleRegionInfo> neighbours =
413 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
414 //IPEndPoint blah = new IPEndPoint();
415
416 //blah.Address = region.RemotingAddress;
417 //blah.Port = region.RemotingPort;
418 }
419
420 public List<SimpleRegionInfo> RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
421 { 394 {
422 Border[] northBorders = pScene.NorthBorders.ToArray(); 395 Border[] northBorders = pScene.NorthBorders.ToArray();
423 Border[] southBorders = pScene.SouthBorders.ToArray(); 396 Border[] southBorders = pScene.SouthBorders.ToArray();
@@ -427,50 +400,34 @@ namespace OpenSim.Region.Framework.Scenes
427 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. 400 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
428 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) 401 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
429 { 402 {
430 return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 403 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
431 } 404 }
432 else 405 else
433 { 406 {
434 Vector2 extent = Vector2.Zero; 407 Vector2 extent = Vector2.Zero;
435 for (int i=0;i<eastBorders.Length;i++) 408 for (int i = 0; i < eastBorders.Length; i++)
436 { 409 {
437 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; 410 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
438 } 411 }
439 for (int i=0;i<northBorders.Length;i++) 412 for (int i = 0; i < northBorders.Length; i++)
440 { 413 {
441 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; 414 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
442 } 415 }
443 416
444 List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
445
446 // Loss of fraction on purpose 417 // Loss of fraction on purpose
447 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; 418 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
448 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; 419 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
449 420
450 int startX = (int) pRegionLocX - 1; 421 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
451 int startY = (int) pRegionLocY - 1; 422 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
452 423
453 int endX = (int) pRegionLocX + (int)extent.X; 424 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
454 int endY = (int) pRegionLocY + (int)extent.Y; 425 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
455 426
456 for (int i=startX;i<endX;i++) 427 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
457 { 428 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
458 for (int j=startY;j<endY;j++) 429
459 { 430 return neighbours;
460 // Skip CurrentRegion
461 if (i == (int)pRegionLocX && j == (int)pRegionLocY)
462 continue;
463
464 ulong regionHandle = Util.UIntsToLong((uint)(i * Constants.RegionSize),
465 (uint)(j * Constants.RegionSize));
466 RegionInfo neighborreg = m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
467 if (neighborreg != null)
468 {
469 neighbourList.Add(neighborreg);
470 }
471 }
472 }
473 return neighbourList;
474 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo() 431 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
475 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 432 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
476 } 433 }
@@ -482,29 +439,28 @@ namespace OpenSim.Region.Framework.Scenes
482 /// </summary> 439 /// </summary>
483 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) 440 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
484 { 441 {
485 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 442 //List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
443 List<GridRegion> neighbours = new List<GridRegion>();
486 444
487 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 445 ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
488 for (int i = 0; i < lstneighbours.Count; i++) 446 //for (int i = 0; i < lstneighbours.Count; i++)
489 { 447 //{
490 // We don't want to keep sending to regions that consistently fail on comms. 448 // // We don't want to keep sending to regions that consistently fail on comms.
491 if (!(lstneighbours[i].commFailTF)) 449 // if (!(lstneighbours[i].commFailTF))
492 { 450 // {
493 neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); 451 // neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
494 } 452 // }
495 } 453 //}
496 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be 454 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
497 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/ 455 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
498 if (m_regionInfo != null) 456 if (m_regionInfo != null)
499 { 457 {
500 neighbours = 458 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
501 RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
502 } 459 }
503 else 460 else
504 { 461 {
505 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?"); 462 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
506 } 463 }
507
508 464
509 /// We need to find the difference between the new regions where there are no child agents 465 /// We need to find the difference between the new regions where there are no child agents
510 /// and the regions where there are already child agents. We only send notification to the former. 466 /// and the regions where there are already child agents. We only send notification to the former.
@@ -547,8 +503,9 @@ namespace OpenSim.Region.Framework.Scenes
547 503
548 /// Create the necessary child agents 504 /// Create the necessary child agents
549 List<AgentCircuitData> cagents = new List<AgentCircuitData>(); 505 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
550 foreach (SimpleRegionInfo neighbour in neighbours) 506 //foreach (SimpleRegionInfo neighbour in neighbours)
551 { 507 foreach (GridRegion neighbour in neighbours)
508 {
552 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) 509 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
553 { 510 {
554 511
@@ -588,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
588 545
589 bool newAgent = false; 546 bool newAgent = false;
590 int count = 0; 547 int count = 0;
591 foreach (SimpleRegionInfo neighbour in neighbours) 548 foreach (GridRegion neighbour in neighbours)
592 { 549 {
593 // Don't do it if there's already an agent in that region 550 // Don't do it if there's already an agent in that region
594 if (newRegions.Contains(neighbour.RegionHandle)) 551 if (newRegions.Contains(neighbour.RegionHandle))
@@ -641,7 +598,7 @@ namespace OpenSim.Region.Framework.Scenes
641 /// This informs a single neighboring region about agent "avatar". 598 /// This informs a single neighboring region about agent "avatar".
642 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 599 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
643 /// </summary> 600 /// </summary>
644 public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region) 601 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
645 { 602 {
646 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 603 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
647 agent.BaseFolder = UUID.Zero; 604 agent.BaseFolder = UUID.Zero;
@@ -672,61 +629,63 @@ namespace OpenSim.Region.Framework.Scenes
672 /// <param name="regionhandle"></param> 629 /// <param name="regionhandle"></param>
673 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle) 630 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
674 { 631 {
675 m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here"); 632 uint x = 0, y = 0;
676 //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); 633 Utils.LongToUInts(regionhandle, out x, out y);
677
678 //bool regionAccepted =
679 // m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
680 634
681 //bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region); 635 GridRegion neighbour = null;
682 bool regionAccepted = false;
683 if (neighbourService != null) 636 if (neighbourService != null)
684 regionAccepted = neighbourService.HelloNeighbour(regionhandle, region); 637 neighbour = neighbourService.HelloNeighbour(regionhandle, region);
685 else 638 else
686 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region"); 639 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");
687 640
688 if (regionAccepted) 641 if (neighbour != null)
689 { 642 {
690 m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here"); 643 m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
691 handlerRegionUp = OnRegionUp; 644 m_scene.EventManager.TriggerOnRegionUp(neighbour);
692
693 // yes, we're notifying ourselves.
694 if (handlerRegionUp != null)
695 handlerRegionUp(region);
696 } 645 }
697 else 646 else
698 { 647 {
699 m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here."); 648 m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
700 } 649 }
701 } 650 }
702 651
703 /// <summary> 652
704 /// Called by scene when region is initialized (not always when it's listening for agents)
705 /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
706 /// </summary>
707 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region) 653 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
708 { 654 {
709 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 655 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
710 656
711 657 for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++)
712 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 658 for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++)
713 // This stays uncached because we don't already know about our neighbors at this point. 659 if (!((x == region.RegionLocX) && (y == region.RegionLocY))) // skip this region
714 neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 660 {
715 if (neighbours != null) 661 ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize);
716 { 662 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
717 for (int i = 0; i < neighbours.Count; i++)
718 {
719 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
720 663
721 d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle, 664 d.BeginInvoke(neighbourService, region, handle,
722 InformNeighborsThatRegionisUpCompleted, 665 InformNeighborsThatRegionisUpCompleted,
723 d); 666 d);
724 } 667 }
725 } 668
669 //List<GridRegion> neighbours = new List<GridRegion>();
670 //// This stays uncached because we don't already know about our neighbors at this point.
671
672 //neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
673 //if (neighbours != null)
674 //{
675 // for (int i = 0; i < neighbours.Count; i++)
676 // {
677 // InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
678
679 // d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
680 // InformNeighborsThatRegionisUpCompleted,
681 // d);
682 // }
683 //}
726 684
727 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); 685 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
728 } 686 }
729 687
688
730 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); 689 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
731 690
732 /// <summary> 691 /// <summary>
@@ -822,41 +781,6 @@ namespace OpenSim.Region.Framework.Scenes
822 } 781 }
823 } 782 }
824 783
825 /// <summary>
826 /// Helper function to request neighbors from grid-comms
827 /// </summary>
828 /// <param name="regionHandle"></param>
829 /// <returns></returns>
830 public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
831 {
832 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
833 return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
834 }
835
836 /// <summary>
837 /// Helper function to request neighbors from grid-comms
838 /// </summary>
839 /// <param name="regionID"></param>
840 /// <returns></returns>
841 public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
842 {
843 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
844 return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
845 }
846
847 /// <summary>
848 /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
849 /// </summary>
850 /// <param name="minX"></param>
851 /// <param name="minY"></param>
852 /// <param name="maxX"></param>
853 /// <param name="maxY"></param>
854 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
855 {
856 List<MapBlockData> mapBlocks;
857 mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
858 remoteClient.SendMapBlock(mapBlocks, 0);
859 }
860 784
861 /// <summary> 785 /// <summary>
862 /// Try to teleport an agent to a new region. 786 /// Try to teleport an agent to a new region.
@@ -921,7 +845,10 @@ namespace OpenSim.Region.Framework.Scenes
921 } 845 }
922 else 846 else
923 { 847 {
924 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 848 uint x = 0, y = 0;
849 Utils.LongToUInts(regionHandle, out x, out y);
850 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
851
925 if (reg != null) 852 if (reg != null)
926 { 853 {
927 m_log.DebugFormat( 854 m_log.DebugFormat(
@@ -1228,10 +1155,10 @@ namespace OpenSim.Region.Framework.Scenes
1228 return false; 1155 return false;
1229 } 1156 }
1230 1157
1231 private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours) 1158 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1232 { 1159 {
1233 List<ulong> handles = new List<ulong>(); 1160 List<ulong> handles = new List<ulong>();
1234 foreach (SimpleRegionInfo reg in neighbours) 1161 foreach (GridRegion reg in neighbours)
1235 { 1162 {
1236 handles.Add(reg.RegionHandle); 1163 handles.Add(reg.RegionHandle);
1237 } 1164 }
@@ -1482,7 +1409,10 @@ namespace OpenSim.Region.Framework.Scenes
1482 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); 1409 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1483 1410
1484 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 1411 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1485 SimpleRegionInfo neighbourRegion = RequestNeighbouringRegionInfo(neighbourHandle); 1412
1413 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1414 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1415
1486 if (neighbourRegion != null && agent.ValidateAttachments()) 1416 if (neighbourRegion != null && agent.ValidateAttachments())
1487 { 1417 {
1488 pos = pos + (agent.Velocity); 1418 pos = pos + (agent.Velocity);
@@ -1609,11 +1539,6 @@ namespace OpenSim.Region.Framework.Scenes
1609 } 1539 }
1610 1540
1611 1541
1612 public Dictionary<string, string> GetGridSettings()
1613 {
1614 return m_commsProvider.GridService.GetGridSettings();
1615 }
1616
1617 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) 1542 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1618 { 1543 {
1619 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); 1544 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@@ -1650,19 +1575,14 @@ namespace OpenSim.Region.Framework.Scenes
1650 return m_commsProvider.GetUserFriendList(friendlistowner); 1575 return m_commsProvider.GetUserFriendList(friendlistowner);
1651 } 1576 }
1652 1577
1653 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
1654 {
1655 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
1656 }
1657
1658 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) 1578 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1659 { 1579 {
1660 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 1580 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1661 } 1581 }
1662 1582
1663 public List<RegionInfo> RequestNamedRegions(string name, int maxNumber) 1583 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1664 { 1584 {
1665 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); 1585 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1666 } 1586 }
1667 1587
1668 //private void Dump(string msg, List<ulong> handles) 1588 //private void Dump(string msg, List<ulong> handles)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6772f75..286b7ca 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework.Communications.Cache;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes.Types; 37using OpenSim.Region.Framework.Scenes.Types;
38using OpenSim.Region.Physics.Manager; 38using OpenSim.Region.Physics.Manager;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
41{ 42{
@@ -2934,8 +2935,9 @@ namespace OpenSim.Region.Framework.Scenes
2934 else if (dir > 3 && dir < 7) // Heading Sout 2935 else if (dir > 3 && dir < 7) // Heading Sout
2935 neighboury--; 2936 neighboury--;
2936 2937
2937 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 2938 int x = (int)(neighbourx * Constants.RegionSize);
2938 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 2939 int y = (int)(neighboury * Constants.RegionSize);
2940 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
2939 2941
2940 if (neighbourRegion == null) 2942 if (neighbourRegion == null)
2941 { 2943 {
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index f6737a5..5c9e66f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -29,6 +29,7 @@ using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
32 33
33namespace OpenSim.Region.Framework.Scenes.Tests 34namespace OpenSim.Region.Framework.Scenes.Tests
34{ 35{
@@ -65,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
65 throw new NotImplementedException(); 66 throw new NotImplementedException();
66 } 67 }
67 68
68 public override bool OtherRegionUp(RegionInfo thisRegion) 69 public override void OtherRegionUp(GridRegion otherRegion)
69 { 70 {
70 throw new NotImplementedException(); 71 throw new NotImplementedException();
71 } 72 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4c52b11..1ebe24e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
50using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 50using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
51using OpenSim.Region.ScriptEngine.Interfaces; 51using OpenSim.Region.ScriptEngine.Interfaces;
52using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 52using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
53using OpenSim.Services.Interfaces;
54
55using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53 56
54using AssetLandmark = OpenSim.Framework.AssetLandmark; 57using AssetLandmark = OpenSim.Framework.AssetLandmark;
55 58
@@ -5226,12 +5229,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5226 } 5229 }
5227 } 5230 }
5228 5231
5229 List<SimpleRegionInfo> neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY); 5232 List<GridRegion> neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID);
5230 5233
5231 uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; 5234 uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x;
5232 uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; 5235 uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y;
5233 5236
5234 foreach (SimpleRegionInfo sri in neighbors) 5237 foreach (GridRegion sri in neighbors)
5235 { 5238 {
5236 if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) 5239 if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY)
5237 return 0; 5240 return 0;
@@ -8181,7 +8184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8181 8184
8182 string reply = String.Empty; 8185 string reply = String.Empty;
8183 8186
8184 RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator); 8187 GridRegion info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator);
8185 8188
8186 switch (data) 8189 switch (data)
8187 { 8190 {
@@ -8208,7 +8211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8208 ConditionalScriptSleep(1000); 8211 ConditionalScriptSleep(1000);
8209 return UUID.Zero.ToString(); 8212 return UUID.Zero.ToString();
8210 } 8213 }
8211 int access = info.RegionSettings.Maturity; 8214 int access = info.Maturity;
8212 if (access == 0) 8215 if (access == 0)
8213 reply = "PG"; 8216 reply = "PG";
8214 else if (access == 1) 8217 else if (access == 1)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index ccdd4c5..0b95abc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -48,6 +48,8 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
48using OpenSim.Region.ScriptEngine.Interfaces; 48using OpenSim.Region.ScriptEngine.Interfaces;
49using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 49using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
50using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 50using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
51using OpenSim.Services.Interfaces;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion;
51using System.Text.RegularExpressions; 53using System.Text.RegularExpressions;
52 54
53using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 55using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
@@ -599,17 +601,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
599 if (regionName.Contains(".") && regionName.Contains(":")) 601 if (regionName.Contains(".") && regionName.Contains(":"))
600 { 602 {
601 // Try to link the region 603 // Try to link the region
602 RegionInfo regInfo = HGHyperlink.TryLinkRegion(World, 604 IHyperlinkService hyperService = World.RequestModuleInterface<IHyperlinkService>();
603 presence.ControllingClient, 605 if (hyperService != null)
604 regionName);
605 // Get the region name
606 if (regInfo != null)
607 { 606 {
608 regionName = regInfo.RegionName; 607 GridRegion regInfo = hyperService.TryLinkRegion(presence.ControllingClient,
609 } 608 regionName);
610 else 609 // Get the region name
611 { 610 if (regInfo != null)
612 // Might need to ping the client here in case of failure?? 611 {
612 regionName = regInfo.RegionName;
613 }
614 else
615 {
616 // Might need to ping the client here in case of failure??
617 }
613 } 618 }
614 } 619 }
615 presence.ControllingClient.SendTeleportLocationStart(); 620 presence.ControllingClient.SendTeleportLocationStart();
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
index ad63485..c47f652 100644
--- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -36,7 +36,9 @@ using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Servers.HttpServer; 37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base; 38using OpenSim.Server.Handlers.Base;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
41using OpenMetaverse;
40using log4net; 42using log4net;
41using Nwc.XmlRpc; 43using Nwc.XmlRpc;
42 44
@@ -48,12 +50,26 @@ namespace OpenSim.Server.Handlers.Grid
48 LogManager.GetLogger( 50 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
50 52
51 private List<SimpleRegionInfo> m_RegionsOnSim = new List<SimpleRegionInfo>(); 53 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
54 private IHyperlinkService m_HyperlinkService;
52 55
53 public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : 56 public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
54 base(config, server) 57 base(config, server)
55 { 58 {
56 server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false); 59 m_HyperlinkService = hyperService;
60 server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
61 server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
62 }
63
64 public void AddRegion(GridRegion rinfo)
65 {
66 m_RegionsOnSim.Add(rinfo);
67 }
68
69 public void RemoveRegion(GridRegion rinfo)
70 {
71 if (m_RegionsOnSim.Contains(rinfo))
72 m_RegionsOnSim.Remove(rinfo);
57 } 73 }
58 74
59 /// <summary> 75 /// <summary>
@@ -70,8 +86,8 @@ namespace OpenSim.Server.Handlers.Grid
70 86
71 m_log.DebugFormat("[HGrid]: Hyperlink request"); 87 m_log.DebugFormat("[HGrid]: Hyperlink request");
72 88
73 SimpleRegionInfo regInfo = null; 89 GridRegion regInfo = null;
74 foreach (SimpleRegionInfo r in m_RegionsOnSim) 90 foreach (GridRegion r in m_RegionsOnSim)
75 { 91 {
76 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) 92 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
77 { 93 {
@@ -85,9 +101,9 @@ namespace OpenSim.Server.Handlers.Grid
85 101
86 Hashtable hash = new Hashtable(); 102 Hashtable hash = new Hashtable();
87 hash["uuid"] = regInfo.RegionID.ToString(); 103 hash["uuid"] = regInfo.RegionID.ToString();
104 m_log.Debug(">> Here " + regInfo.RegionID);
88 hash["handle"] = regInfo.RegionHandle.ToString(); 105 hash["handle"] = regInfo.RegionHandle.ToString();
89 //m_log.Debug(">> Here " + regInfo.RegionHandle); 106 hash["region_image"] = regInfo.TerrainImage.ToString();
90 //hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
91 hash["region_name"] = regInfo.RegionName; 107 hash["region_name"] = regInfo.RegionName;
92 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); 108 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
93 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); 109 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
@@ -98,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid
98 return response; 114 return response;
99 } 115 }
100 116
101 public void AddRegion(SimpleRegionInfo rinfo) 117 /// <summary>
118 /// Received from other HGrid nodes when a user wants to teleport here. This call allows
119 /// the region to prepare for direct communication from the client. Sends back an empty
120 /// xmlrpc response on completion.
121 /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
122 /// registering the user in the local user cache.
123 /// </summary>
124 /// <param name="request"></param>
125 /// <returns></returns>
126 public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
102 { 127 {
103 m_RegionsOnSim.Add(rinfo); 128 Hashtable requestData = (Hashtable)request.Params[0];
104 } 129 ForeignUserProfileData userData = new ForeignUserProfileData();
105 130
106 public void RemoveRegion(SimpleRegionInfo rinfo) 131 userData.FirstName = (string)requestData["firstname"];
107 { 132 userData.SurName = (string)requestData["lastname"];
108 if (m_RegionsOnSim.Contains(rinfo)) 133 userData.ID = new UUID((string)requestData["agent_id"]);
109 m_RegionsOnSim.Remove(rinfo); 134 UUID sessionID = new UUID((string)requestData["session_id"]);
135 userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
136 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
137 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
138
139 userData.UserServerURI = (string)requestData["userserver_id"];
140 userData.UserAssetURI = (string)requestData["assetserver_id"];
141 userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
142
143 m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
144 userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
145
146 ulong userRegionHandle = 0;
147 int userhomeinternalport = 0;
148 if (requestData.ContainsKey("region_uuid"))
149 {
150 UUID uuid = UUID.Zero;
151 UUID.TryParse((string)requestData["region_uuid"], out uuid);
152 userData.HomeRegionID = uuid;
153 userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
154 userData.UserHomeAddress = (string)requestData["home_address"];
155 userData.UserHomePort = (string)requestData["home_port"];
156 userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
157
158 m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
159 "; home_port: " + userData.UserHomePort);
160 }
161 else
162 m_log.WarnFormat("[HGrid]: User has no home region information");
163
164 XmlRpcResponse resp = new XmlRpcResponse();
165
166 // Let's check if someone is trying to get in with a stolen local identity.
167 // The need for this test is a consequence of not having truly global names :-/
168 bool comingHome = false;
169 if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
170 {
171 m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
172 Hashtable respdata = new Hashtable();
173 respdata["success"] = "FALSE";
174 respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
175 resp.Value = respdata;
176 return resp;
177 }
178
179 // Finally, everything looks ok
180 //m_log.Debug("XXX---- EVERYTHING OK ---XXX");
181
182 if (!comingHome)
183 {
184 // We don't do this if the user is coming to the home grid
185 GridRegion home = new GridRegion();
186 home.RegionID = userData.HomeRegionID;
187 home.ExternalHostName = userData.UserHomeAddress;
188 home.HttpPort = Convert.ToUInt32(userData.UserHomePort);
189 uint x = 0, y = 0;
190 Utils.LongToUInts(userRegionHandle, out x, out y);
191 home.RegionLocX = (int)x;
192 home.RegionLocY = (int)y;
193 home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
194
195 m_HyperlinkService.AcceptUser(userData, home);
196 }
197 // else the user is coming to a non-home region of the home grid
198 // We simply drop this user information altogether
199
200 Hashtable respdata2 = new Hashtable();
201 respdata2["success"] = "TRUE";
202 resp.Value = respdata2;
203
204 return resp;
110 } 205 }
206
111 } 207 }
112} 208}
diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
index c0933a8..d6ef22e 100644
--- a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
+++ b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
@@ -36,6 +36,7 @@ using OpenSim.Server.Handlers.Base;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40using OpenMetaverse; 41using OpenMetaverse;
41using OpenMetaverse.StructuredData; 42using OpenMetaverse.StructuredData;
@@ -148,11 +149,14 @@ namespace OpenSim.Server.Handlers.Neighbour
148 } 149 }
149 150
150 // Finally! 151 // Finally!
151 bool success = m_NeighbourService.HelloNeighbour(regionhandle, aRegion); 152 GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
152 153
153 OSDMap resp = new OSDMap(1); 154 OSDMap resp = new OSDMap(1);
154 155
155 resp["success"] = OSD.FromBoolean(success); 156 if (thisRegion != null)
157 resp["success"] = OSD.FromBoolean(true);
158 else
159 resp["success"] = OSD.FromBoolean(false);
156 160
157 httpResponse.StatusCode = (int)HttpStatusCode.OK; 161 httpResponse.StatusCode = (int)HttpStatusCode.OK;
158 162
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
index b5e8743..dd19b01 100644
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors.Grid
66 IList paramList = new ArrayList(); 66 IList paramList = new ArrayList();
67 paramList.Add(hash); 67 paramList.Add(hash);
68 68
69 XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList); 69 XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
70 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; 70 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
71 m_log.Debug("[HGrid]: Linking to " + uri); 71 m_log.Debug("[HGrid]: Linking to " + uri);
72 XmlRpcResponse response = request.Send(uri, 10000); 72 XmlRpcResponse response = request.Send(uri, 10000);
@@ -82,6 +82,7 @@ namespace OpenSim.Services.Connectors.Grid
82 try 82 try
83 { 83 {
84 UUID.TryParse((string)hash["uuid"], out uuid); 84 UUID.TryParse((string)hash["uuid"], out uuid);
85 m_log.Debug(">> HERE, uuid: " + uuid);
85 info.RegionID = uuid; 86 info.RegionID = uuid;
86 if ((string)hash["handle"] != null) 87 if ((string)hash["handle"] != null)
87 { 88 {
@@ -148,5 +149,94 @@ namespace OpenSim.Services.Connectors.Grid
148 } 149 }
149 } 150 }
150 151
152 public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer)
153 {
154 string capsPath = agentData.CapsPath;
155 Hashtable loginParams = new Hashtable();
156 loginParams["session_id"] = agentData.SessionID.ToString();
157
158 loginParams["firstname"] = agentData.firstname;
159 loginParams["lastname"] = agentData.lastname;
160
161 loginParams["agent_id"] = agentData.AgentID.ToString();
162 loginParams["circuit_code"] = agentData.circuitcode.ToString();
163 loginParams["startpos_x"] = agentData.startpos.X.ToString();
164 loginParams["startpos_y"] = agentData.startpos.Y.ToString();
165 loginParams["startpos_z"] = agentData.startpos.Z.ToString();
166 loginParams["caps_path"] = capsPath;
167
168 if (home != null)
169 {
170 loginParams["region_uuid"] = home.RegionID.ToString();
171 loginParams["regionhandle"] = home.RegionHandle.ToString();
172 loginParams["home_address"] = home.ExternalHostName;
173 loginParams["home_port"] = home.HttpPort.ToString();
174 loginParams["internal_port"] = home.InternalEndPoint.Port.ToString();
175
176 m_log.Debug(" --------- Home -------");
177 m_log.Debug(" >> " + loginParams["home_address"] + " <<");
178 m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
179 m_log.Debug(" >> " + loginParams["regionhandle"] + " <<");
180 m_log.Debug(" >> " + loginParams["home_port"] + " <<");
181 m_log.Debug(" --------- ------------ -------");
182 }
183 else
184 m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname);
185
186 loginParams["userserver_id"] = userServer;
187 loginParams["assetserver_id"] = assetServer;
188 loginParams["inventoryserver_id"] = inventoryServer;
189
190
191 ArrayList SendParams = new ArrayList();
192 SendParams.Add(loginParams);
193
194 // Send
195 string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/";
196 //m_log.Debug("XXX uri: " + uri);
197 XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams);
198 XmlRpcResponse reply;
199 try
200 {
201 reply = request.Send(uri, 6000);
202 }
203 catch (Exception e)
204 {
205 m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message);
206 return false;
207 }
208
209 if (!reply.IsFault)
210 {
211 bool responseSuccess = true;
212 if (reply.Value != null)
213 {
214 Hashtable resp = (Hashtable)reply.Value;
215 if (resp.ContainsKey("success"))
216 {
217 if ((string)resp["success"] == "FALSE")
218 {
219 responseSuccess = false;
220 }
221 }
222 }
223 if (responseSuccess)
224 {
225 m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID);
226 return true;
227 }
228 else
229 {
230 m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients");
231 return false;
232 }
233 }
234 else
235 {
236 m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode);
237 return false;
238 }
239 }
240
151 } 241 }
152} 242}
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
index 0243f1f..06bc11c 100644
--- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39using OpenMetaverse; 39using OpenMetaverse;
40using Nwc.XmlRpc; 40using Nwc.XmlRpc;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41 42
42namespace OpenSim.Services.Connectors 43namespace OpenSim.Services.Connectors
43{ 44{
@@ -47,20 +48,20 @@ namespace OpenSim.Services.Connectors
47 LogManager.GetLogger( 48 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 49 MethodBase.GetCurrentMethod().DeclaringType);
49 50
50 protected IGridServices m_MapService = null; 51 protected IGridService m_GridService = null;
51 52
52 public LandServicesConnector() 53 public LandServicesConnector()
53 { 54 {
54 } 55 }
55 56
56 public LandServicesConnector(IGridServices gridServices) 57 public LandServicesConnector(IGridService gridServices)
57 { 58 {
58 Initialise(gridServices); 59 Initialise(gridServices);
59 } 60 }
60 61
61 public virtual void Initialise(IGridServices gridServices) 62 public virtual void Initialise(IGridService gridServices)
62 { 63 {
63 m_MapService = gridServices; 64 m_GridService = gridServices;
64 } 65 }
65 66
66 public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) 67 public virtual LandData GetLandData(ulong regionHandle, uint x, uint y)
@@ -76,7 +77,9 @@ namespace OpenSim.Services.Connectors
76 77
77 try 78 try
78 { 79 {
79 RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle); 80 uint xpos = 0, ypos = 0;
81 Utils.LongToUInts(regionHandle, out xpos, out ypos);
82 GridRegion info = m_GridService.GetRegionByPosition(UUID.Zero, (int)xpos, (int)ypos);
80 if (info != null) // just to be sure 83 if (info != null) // just to be sure
81 { 84 {
82 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); 85 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
index 7fff537..145f212 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
@@ -41,6 +41,8 @@ using OpenSim.Services.Interfaces;
41using OpenMetaverse; 41using OpenMetaverse;
42using OpenMetaverse.StructuredData; 42using OpenMetaverse.StructuredData;
43 43
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
45
44namespace OpenSim.Services.Connectors 46namespace OpenSim.Services.Connectors
45{ 47{
46 public class NeighbourServicesConnector : INeighbourService 48 public class NeighbourServicesConnector : INeighbourService
@@ -49,37 +51,39 @@ namespace OpenSim.Services.Connectors
49 LogManager.GetLogger( 51 LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType); 52 MethodBase.GetCurrentMethod().DeclaringType);
51 53
52 protected IGridServices m_MapService = null; 54 protected IGridService m_GridService = null;
53 55
54 public NeighbourServicesConnector() 56 public NeighbourServicesConnector()
55 { 57 {
56 } 58 }
57 59
58 public NeighbourServicesConnector(IGridServices gridServices) 60 public NeighbourServicesConnector(IGridService gridServices)
59 { 61 {
60 Initialise(gridServices); 62 Initialise(gridServices);
61 } 63 }
62 64
63 public virtual void Initialise(IGridServices gridServices) 65 public virtual void Initialise(IGridService gridServices)
64 { 66 {
65 m_MapService = gridServices; 67 m_GridService = gridServices;
66 } 68 }
67 69
68 public virtual bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 70 public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
69 { 71 {
70 RegionInfo regInfo = m_MapService.RequestNeighbourInfo(regionHandle); 72 uint x = 0, y = 0;
73 Utils.LongToUInts(regionHandle, out x, out y);
74 GridRegion regInfo = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
71 if ((regInfo != null) && 75 if ((regInfo != null) &&
72 // Don't remote-call this instance; that's a startup hickup 76 // Don't remote-call this instance; that's a startup hickup
73 !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) 77 !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort)))
74 { 78 {
75 return DoHelloNeighbourCall(regInfo, thisRegion); 79 DoHelloNeighbourCall(regInfo, thisRegion);
76 } 80 }
77 //else 81 //else
78 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); 82 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
79 return false; 83 return regInfo;
80 } 84 }
81 85
82 public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) 86 public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion)
83 { 87 {
84 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; 88 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/";
85 //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); 89 //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri);
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index ce432ab..c5495fb 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -122,9 +122,6 @@ namespace OpenSim.Services.Interfaces
122 } 122 }
123 protected string m_regionName = String.Empty; 123 protected string m_regionName = String.Empty;
124 124
125 protected bool Allow_Alternate_Ports;
126 public bool m_allow_alternate_ports;
127
128 protected string m_externalHostName; 125 protected string m_externalHostName;
129 126
130 protected IPEndPoint m_internalEndPoint; 127 protected IPEndPoint m_internalEndPoint;
@@ -146,6 +143,10 @@ namespace OpenSim.Services.Interfaces
146 public UUID RegionID = UUID.Zero; 143 public UUID RegionID = UUID.Zero;
147 public UUID ScopeID = UUID.Zero; 144 public UUID ScopeID = UUID.Zero;
148 145
146 public UUID TerrainImage = UUID.Zero;
147 public byte Access;
148 public int Maturity;
149
149 public GridRegion() 150 public GridRegion()
150 { 151 {
151 } 152 }
@@ -183,11 +184,27 @@ namespace OpenSim.Services.Interfaces
183 m_internalEndPoint = ConvertFrom.InternalEndPoint; 184 m_internalEndPoint = ConvertFrom.InternalEndPoint;
184 m_externalHostName = ConvertFrom.ExternalHostName; 185 m_externalHostName = ConvertFrom.ExternalHostName;
185 m_httpPort = ConvertFrom.HttpPort; 186 m_httpPort = ConvertFrom.HttpPort;
186 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; 187 RegionID = ConvertFrom.RegionID;
187 RegionID = UUID.Zero;
188 ServerURI = ConvertFrom.ServerURI; 188 ServerURI = ConvertFrom.ServerURI;
189 TerrainImage = ConvertFrom.RegionSettings.TerrainImageID;
190 Access = ConvertFrom.AccessLevel;
191 Maturity = ConvertFrom.RegionSettings.Maturity;
189 } 192 }
190 193
194 public GridRegion(GridRegion ConvertFrom)
195 {
196 m_regionName = ConvertFrom.RegionName;
197 m_regionLocX = ConvertFrom.RegionLocX;
198 m_regionLocY = ConvertFrom.RegionLocY;
199 m_internalEndPoint = ConvertFrom.InternalEndPoint;
200 m_externalHostName = ConvertFrom.ExternalHostName;
201 m_httpPort = ConvertFrom.HttpPort;
202 RegionID = ConvertFrom.RegionID;
203 ServerURI = ConvertFrom.ServerURI;
204 TerrainImage = ConvertFrom.TerrainImage;
205 Access = ConvertFrom.Access;
206 Maturity = ConvertFrom.Maturity;
207 }
191 208
192 /// <value> 209 /// <value>
193 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. 210 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
@@ -268,7 +285,9 @@ namespace OpenSim.Services.Interfaces
268 kvp["serverHttpPort"] = HttpPort.ToString(); 285 kvp["serverHttpPort"] = HttpPort.ToString();
269 kvp["serverURI"] = ServerURI; 286 kvp["serverURI"] = ServerURI;
270 kvp["serverPort"] = InternalEndPoint.Port.ToString(); 287 kvp["serverPort"] = InternalEndPoint.Port.ToString();
271 288 kvp["regionMapTexture"] = TerrainImage.ToString();
289 kvp["access"] = Access.ToString();
290 // Maturity doesn't seem to exist in the DB
272 return kvp; 291 return kvp;
273 } 292 }
274 293
@@ -312,6 +331,16 @@ namespace OpenSim.Services.Interfaces
312 331
313 if (kvp.ContainsKey("serverURI")) 332 if (kvp.ContainsKey("serverURI"))
314 ServerURI = (string)kvp["serverURI"]; 333 ServerURI = (string)kvp["serverURI"];
334
335 if (kvp.ContainsKey("regionMapTexture"))
336 {
337 UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage);
338 }
339
340 if (kvp.ContainsKey("access"))
341 {
342 Access = Byte.Parse((string)kvp["access"]); ;
343 }
315 } 344 }
316 } 345 }
317 346
diff --git a/OpenSim/Services/Interfaces/IHyperlink.cs b/OpenSim/Services/Interfaces/IHyperlink.cs
new file mode 100644
index 0000000..ed3ff23
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IHyperlink.cs
@@ -0,0 +1,49 @@
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
28using OpenSim.Framework;
29using GridRegion = OpenSim.Services.Interfaces.GridRegion;
30
31using OpenMetaverse;
32
33namespace OpenSim.Services.Interfaces
34{
35 public interface IHyperlinkService
36 {
37 GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor);
38 GridRegion GetHyperlinkRegion(ulong handle);
39 ulong FindRegionHandle(ulong handle);
40
41 bool SendUserInformation(GridRegion region, AgentCircuitData aCircuit);
42 void AdjustUserInformation(AgentCircuitData aCircuit);
43
44 bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome);
45 void AcceptUser(ForeignUserProfileData user, GridRegion home);
46
47 bool IsLocalUser(UUID userID);
48 }
49}
diff --git a/OpenSim/Services/Interfaces/INeighbourService.cs b/OpenSim/Services/Interfaces/INeighbourService.cs
index 3944486..960e13d 100644
--- a/OpenSim/Services/Interfaces/INeighbourService.cs
+++ b/OpenSim/Services/Interfaces/INeighbourService.cs
@@ -28,11 +28,12 @@
28using System; 28using System;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using GridRegion = OpenSim.Services.Interfaces.GridRegion;
31 32
32namespace OpenSim.Services.Interfaces 33namespace OpenSim.Services.Interfaces
33{ 34{
34 public interface INeighbourService 35 public interface INeighbourService
35 { 36 {
36 bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion); 37 GridRegion HelloNeighbour(ulong regionHandle, RegionInfo otherRegion);
37 } 38 }
38} 39}
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
index 941406e..ccda661 100644
--- a/OpenSim/Tests/Clients/Grid/GridClient.cs
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -28,7 +28,7 @@ namespace OpenSim.Tests.Clients.GridClient
28 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); 28 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
29 log4net.Config.BasicConfigurator.Configure(consoleAppender); 29 log4net.Config.BasicConfigurator.Configure(consoleAppender);
30 30
31 string serverURI = "http://127.0.0.1:8002"; 31 string serverURI = "http://127.0.0.1:8001";
32 GridServicesConnector m_Connector = new GridServicesConnector(serverURI); 32 GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
33 33
34 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); 34 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
index 4313c96..de73663 100644
--- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
+++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs
@@ -65,8 +65,6 @@ namespace OpenSim.Tests.Common.Mock
65 m_userService = lus; 65 m_userService = lus;
66 m_userAdminService = lus; 66 m_userAdminService = lus;
67 67
68 LocalBackEndServices gs = new LocalBackEndServices();
69 m_gridService = gs;
70 } 68 }
71 } 69 }
72} 70}