diff options
author | Melanie | 2010-01-19 04:18:01 +0000 |
---|---|---|
committer | Melanie | 2010-01-19 04:18:01 +0000 |
commit | a3f48a7ca66347b11990e5444a636d40bec5dbf1 (patch) | |
tree | a5708996ccf28ce8696b8257a0b33352f56e2afe /OpenSim/Services/Connectors | |
parent | Add a Hyperlink flag to the regions table (diff) | |
parent | * Towards enabling hyperlinks at grid-level. (diff) | |
download | opensim-SC-a3f48a7ca66347b11990e5444a636d40bec5dbf1.zip opensim-SC-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.gz opensim-SC-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.bz2 opensim-SC-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.xz |
Merge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensim into presence-refactor
Diffstat (limited to '')
3 files changed, 358 insertions, 3 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs new file mode 100644 index 0000000..a8d9292 --- /dev/null +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -0,0 +1,119 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | |||
6 | using OpenSim.Services.Interfaces; | ||
7 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
8 | |||
9 | using OpenMetaverse; | ||
10 | using Nwc.XmlRpc; | ||
11 | |||
12 | using OpenSim.Services.Connectors.Simulation; | ||
13 | |||
14 | namespace OpenSim.Services.Connectors.Hypergrid | ||
15 | { | ||
16 | public class GatekeeperServiceConnector : SimulationServiceConnector | ||
17 | { | ||
18 | protected override string AgentPath() | ||
19 | { | ||
20 | return "/foreignagent/"; | ||
21 | } | ||
22 | |||
23 | protected override string ObjectPath() | ||
24 | { | ||
25 | return "/foreignobject/"; | ||
26 | } | ||
27 | |||
28 | public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt) | ||
29 | { | ||
30 | position = Vector3.UnitY; lookAt = Vector3.UnitY; | ||
31 | |||
32 | Hashtable hash = new Hashtable(); | ||
33 | hash["userID"] = userID.ToString(); | ||
34 | |||
35 | IList paramList = new ArrayList(); | ||
36 | paramList.Add(hash); | ||
37 | |||
38 | XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); | ||
39 | string uri = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort + "/"; | ||
40 | XmlRpcResponse response = null; | ||
41 | try | ||
42 | { | ||
43 | response = request.Send(uri, 10000); | ||
44 | } | ||
45 | catch (Exception e) | ||
46 | { | ||
47 | return null; | ||
48 | } | ||
49 | |||
50 | if (response.IsFault) | ||
51 | { | ||
52 | return null; | ||
53 | } | ||
54 | |||
55 | hash = (Hashtable)response.Value; | ||
56 | //foreach (Object o in hash) | ||
57 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
58 | try | ||
59 | { | ||
60 | bool success = false; | ||
61 | Boolean.TryParse((string)hash["result"], out success); | ||
62 | if (success) | ||
63 | { | ||
64 | GridRegion region = new GridRegion(); | ||
65 | |||
66 | UUID.TryParse((string)hash["uuid"], out region.RegionID); | ||
67 | //m_log.Debug(">> HERE, uuid: " + region.RegionID); | ||
68 | int n = 0; | ||
69 | if (hash["x"] != null) | ||
70 | { | ||
71 | Int32.TryParse((string)hash["x"], out n); | ||
72 | region.RegionLocX = n; | ||
73 | //m_log.Debug(">> HERE, x: " + region.RegionLocX); | ||
74 | } | ||
75 | if (hash["y"] != null) | ||
76 | { | ||
77 | Int32.TryParse((string)hash["y"], out n); | ||
78 | region.RegionLocY = n; | ||
79 | //m_log.Debug(">> HERE, y: " + region.RegionLocY); | ||
80 | } | ||
81 | if (hash["region_name"] != null) | ||
82 | { | ||
83 | region.RegionName = (string)hash["region_name"]; | ||
84 | //m_log.Debug(">> HERE, name: " + region.RegionName); | ||
85 | } | ||
86 | if (hash["hostname"] != null) | ||
87 | region.ExternalHostName = (string)hash["hostname"]; | ||
88 | if (hash["http_port"] != null) | ||
89 | { | ||
90 | uint p = 0; | ||
91 | UInt32.TryParse((string)hash["http_port"], out p); | ||
92 | region.HttpPort = p; | ||
93 | } | ||
94 | if (hash["internal_port"] != null) | ||
95 | { | ||
96 | int p = 0; | ||
97 | Int32.TryParse((string)hash["internal_port"], out p); | ||
98 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | ||
99 | } | ||
100 | if (hash["position"] != null) | ||
101 | Vector3.TryParse((string)hash["position"], out position); | ||
102 | if (hash["lookAt"] != null) | ||
103 | Vector3.TryParse((string)hash["lookAt"], out lookAt); | ||
104 | |||
105 | // Successful return | ||
106 | return region; | ||
107 | } | ||
108 | |||
109 | } | ||
110 | catch (Exception e) | ||
111 | { | ||
112 | return null; | ||
113 | } | ||
114 | |||
115 | return null; | ||
116 | |||
117 | } | ||
118 | } | ||
119 | } | ||
diff --git a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs new file mode 100644 index 0000000..150690b --- /dev/null +++ b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs | |||
@@ -0,0 +1,132 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | using System.Reflection; | ||
6 | |||
7 | using OpenSim.Services.Interfaces; | ||
8 | |||
9 | using OpenMetaverse; | ||
10 | using log4net; | ||
11 | using Nwc.XmlRpc; | ||
12 | using Nini.Config; | ||
13 | |||
14 | namespace OpenSim.Services.Connectors.Hypergrid | ||
15 | { | ||
16 | public class HomeUsersSecurityServiceConnector : IHomeUsersSecurityService | ||
17 | { | ||
18 | private static readonly ILog m_log = | ||
19 | LogManager.GetLogger( | ||
20 | MethodBase.GetCurrentMethod().DeclaringType); | ||
21 | |||
22 | string m_ServerURL; | ||
23 | public HomeUsersSecurityServiceConnector(string url) | ||
24 | { | ||
25 | m_ServerURL = url; | ||
26 | } | ||
27 | |||
28 | public HomeUsersSecurityServiceConnector(IConfigSource config) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | public void SetEndPoint(UUID sessionID, IPEndPoint ep) | ||
33 | { | ||
34 | Hashtable hash = new Hashtable(); | ||
35 | hash["sessionID"] = sessionID.ToString(); | ||
36 | hash["ep_addr"] = ep.Address.ToString(); | ||
37 | hash["ep_port"] = ep.Port.ToString(); | ||
38 | |||
39 | Call("ep_set", hash); | ||
40 | } | ||
41 | |||
42 | public void RemoveEndPoint(UUID sessionID) | ||
43 | { | ||
44 | Hashtable hash = new Hashtable(); | ||
45 | hash["sessionID"] = sessionID.ToString(); | ||
46 | |||
47 | Call("ep_remove", hash); | ||
48 | } | ||
49 | |||
50 | public IPEndPoint GetEndPoint(UUID sessionID) | ||
51 | { | ||
52 | Hashtable hash = new Hashtable(); | ||
53 | hash["sessionID"] = sessionID.ToString(); | ||
54 | |||
55 | IList paramList = new ArrayList(); | ||
56 | paramList.Add(hash); | ||
57 | |||
58 | XmlRpcRequest request = new XmlRpcRequest("ep_get", paramList); | ||
59 | //m_log.Debug("[HGrid]: Linking to " + uri); | ||
60 | XmlRpcResponse response = null; | ||
61 | try | ||
62 | { | ||
63 | response = request.Send(m_ServerURL, 10000); | ||
64 | } | ||
65 | catch (Exception e) | ||
66 | { | ||
67 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
68 | return null; | ||
69 | } | ||
70 | |||
71 | if (response.IsFault) | ||
72 | { | ||
73 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
74 | return null; | ||
75 | } | ||
76 | |||
77 | hash = (Hashtable)response.Value; | ||
78 | //foreach (Object o in hash) | ||
79 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
80 | try | ||
81 | { | ||
82 | bool success = false; | ||
83 | Boolean.TryParse((string)hash["result"], out success); | ||
84 | if (success) | ||
85 | { | ||
86 | IPEndPoint ep = null; | ||
87 | int port = 0; | ||
88 | if (hash["ep_port"] != null) | ||
89 | Int32.TryParse((string)hash["ep_port"], out port); | ||
90 | if (hash["ep_addr"] != null) | ||
91 | ep = new IPEndPoint(IPAddress.Parse((string)hash["ep_addr"]), port); | ||
92 | |||
93 | return ep; | ||
94 | } | ||
95 | |||
96 | } | ||
97 | catch (Exception e) | ||
98 | { | ||
99 | m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace); | ||
100 | return null; | ||
101 | } | ||
102 | |||
103 | return null; | ||
104 | } | ||
105 | |||
106 | private void Call(string method, Hashtable hash) | ||
107 | { | ||
108 | IList paramList = new ArrayList(); | ||
109 | paramList.Add(hash); | ||
110 | |||
111 | XmlRpcRequest request = new XmlRpcRequest(method, paramList); | ||
112 | XmlRpcResponse response = null; | ||
113 | try | ||
114 | { | ||
115 | response = request.Send(m_ServerURL, 10000); | ||
116 | } | ||
117 | catch (Exception e) | ||
118 | { | ||
119 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
120 | return ; | ||
121 | } | ||
122 | |||
123 | if (response.IsFault) | ||
124 | { | ||
125 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
126 | return ; | ||
127 | } | ||
128 | |||
129 | } | ||
130 | |||
131 | } | ||
132 | } | ||
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; | |||
41 | using OpenMetaverse.Imaging; | 41 | using OpenMetaverse.Imaging; |
42 | using log4net; | 42 | using log4net; |
43 | using Nwc.XmlRpc; | 43 | using Nwc.XmlRpc; |
44 | using Nini.Config; | ||
44 | 45 | ||
45 | namespace OpenSim.Services.Connectors.Hypergrid | 46 | namespace 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 | } |