aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs110
1 files changed, 107 insertions, 3 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
index 953c7bd..1786d38 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs
@@ -41,22 +41,49 @@ using OpenMetaverse;
41using OpenMetaverse.Imaging; 41using OpenMetaverse.Imaging;
42using log4net; 42using log4net;
43using Nwc.XmlRpc; 43using Nwc.XmlRpc;
44using Nini.Config;
44 45
45namespace OpenSim.Services.Connectors.Hypergrid 46namespace OpenSim.Services.Connectors.Hypergrid
46{ 47{
47 public class HypergridServiceConnector 48 public class HypergridServiceConnector : IHypergridService
48 { 49 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 51
51 private IAssetService m_AssetService; 52 private IAssetService m_AssetService;
53 private string m_ServerURL;
52 54
53 public HypergridServiceConnector() : this(null) { } 55 public HypergridServiceConnector() { }
54 56
55 public HypergridServiceConnector(IAssetService assService) 57 public HypergridServiceConnector(IAssetService assService)
56 { 58 {
57 m_AssetService = assService; 59 m_AssetService = assService;
58 } 60 }
59 61
62 public HypergridServiceConnector(IConfigSource source)
63 {
64 Initialise(source);
65 }
66
67 public virtual void Initialise(IConfigSource source)
68 {
69 IConfig hgConfig = source.Configs["HypergridService"];
70 if (hgConfig == null)
71 {
72 m_log.Error("[HYPERGRID CONNECTOR]: HypergridService missing from OpenSim.ini");
73 throw new Exception("Hypergrid connector init error");
74 }
75
76 string serviceURI = hgConfig.GetString("HypergridServerURI",
77 String.Empty);
78
79 if (serviceURI == String.Empty)
80 {
81 m_log.Error("[HYPERGRID CONNECTOR]: No Server URI named in section HypergridService");
82 throw new Exception("Hypergrid connector init error");
83 }
84 m_ServerURL = serviceURI;
85 }
86
60 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) 87 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason)
61 { 88 {
62 regionID = UUID.Zero; 89 regionID = UUID.Zero;
@@ -246,5 +273,82 @@ namespace OpenSim.Services.Connectors.Hypergrid
246 273
247 return null; 274 return null;
248 } 275 }
276
277 #region From local regions to grid-wide hypergrid service
278
279 public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong realHandle, out string imageURL, out string reason)
280 {
281 regionID = UUID.Zero;
282 imageURL = string.Empty;
283 realHandle = 0;
284 reason = string.Empty;
285
286 Hashtable hash = new Hashtable();
287 hash["region_desc"] = regionDescriptor;
288
289 IList paramList = new ArrayList();
290 paramList.Add(hash);
291
292 XmlRpcRequest request = new XmlRpcRequest("link_region_by_desc", paramList);
293 XmlRpcResponse response = null;
294 try
295 {
296 response = request.Send(m_ServerURL, 10000);
297 }
298 catch (Exception e)
299 {
300 m_log.Debug("[HGrid]: Exception " + e.Message);
301 reason = "Error contacting remote server";
302 return false;
303 }
304
305 if (response.IsFault)
306 {
307 reason = response.FaultString;
308 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
309 return false;
310 }
311
312 hash = (Hashtable)response.Value;
313 //foreach (Object o in hash)
314 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
315 try
316 {
317 bool success = false;
318 Boolean.TryParse((string)hash["result"], out success);
319 if (success)
320 {
321 UUID.TryParse((string)hash["uuid"], out regionID);
322 //m_log.Debug(">> HERE, uuid: " + uuid);
323 if ((string)hash["handle"] != null)
324 {
325 realHandle = Convert.ToUInt64((string)hash["handle"]);
326 //m_log.Debug(">> HERE, realHandle: " + realHandle);
327 }
328 if (hash["region_image"] != null)
329 {
330 imageURL = (string)hash["region_image"];
331 }
332 }
333
334 }
335 catch (Exception e)
336 {
337 reason = "Error parsing return arguments";
338 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
339 return false;
340 }
341
342 return true;
343 }
344
345 // TODO !!!
346 public GridRegion GetRegionByUUID(UUID regionID) { return null; }
347 public GridRegion GetRegionByPosition(int x, int y) { return null; }
348 public GridRegion GetRegionByName(string name) { return null; }
349 public List<GridRegion> GetRegionsByName(string name) { return null; }
350 public List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax) { return null; }
351
352 #endregion
249 } 353 }
250} 354}