diff options
author | Diva Canto | 2010-01-18 10:37:11 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-18 10:37:11 -0800 |
commit | fd64823466ee667d0d827f95d3001ec8675512b2 (patch) | |
tree | 8b5b695da9283a693c29d9d1614e12cfeeaa8d5a /OpenSim/Services | |
parent | * Fixed misspelling of field in GridService (diff) | |
download | opensim-SC_OLD-fd64823466ee667d0d827f95d3001ec8675512b2.zip opensim-SC_OLD-fd64823466ee667d0d827f95d3001ec8675512b2.tar.gz opensim-SC_OLD-fd64823466ee667d0d827f95d3001ec8675512b2.tar.bz2 opensim-SC_OLD-fd64823466ee667d0d827f95d3001ec8675512b2.tar.xz |
* Added missing GatekeeperServiceConnector
* Added basic machinery for teleporting users home. Untested.
Diffstat (limited to 'OpenSim/Services')
4 files changed, 163 insertions, 5 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/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 72db93f..55d9ce1 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs | |||
@@ -164,6 +164,7 @@ namespace OpenSim.Services.HypergridService | |||
164 | return region; | 164 | return region; |
165 | } | 165 | } |
166 | 166 | ||
167 | #region Login Agent | ||
167 | public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) | 168 | public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) |
168 | { | 169 | { |
169 | reason = string.Empty; | 170 | reason = string.Empty; |
@@ -221,7 +222,7 @@ namespace OpenSim.Services.HypergridService | |||
221 | return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); | 222 | return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); |
222 | } | 223 | } |
223 | 224 | ||
224 | protected bool Authenticate(AgentCircuitData aCircuit) | 225 | protected bool Authenticate(AgentCircuitData aCircuit) |
225 | { | 226 | { |
226 | string authURL = string.Empty; | 227 | string authURL = string.Empty; |
227 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | 228 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) |
@@ -250,5 +251,40 @@ namespace OpenSim.Services.HypergridService | |||
250 | 251 | ||
251 | return false; | 252 | return false; |
252 | } | 253 | } |
254 | |||
255 | #endregion | ||
256 | |||
257 | public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) | ||
258 | { | ||
259 | position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; | ||
260 | |||
261 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID); | ||
262 | |||
263 | GridRegion home = null; | ||
264 | PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() }); | ||
265 | if (presences != null && presences.Length > 0) | ||
266 | { | ||
267 | UUID homeID = presences[0].HomeRegionID; | ||
268 | if (homeID != UUID.Zero) | ||
269 | { | ||
270 | home = m_GridService.GetRegionByUUID(m_ScopeID, homeID); | ||
271 | position = presences[0].HomePosition; | ||
272 | lookAt = presences[0].HomeLookAt; | ||
273 | } | ||
274 | if (home == null) | ||
275 | { | ||
276 | List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); | ||
277 | if (defs != null && defs.Count > 0) | ||
278 | home = defs[0]; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | return home; | ||
283 | } | ||
284 | |||
285 | #region Misc | ||
286 | |||
287 | |||
288 | #endregion | ||
253 | } | 289 | } |
254 | } | 290 | } |
diff --git a/OpenSim/Services/HypergridService/HypergridService.cs b/OpenSim/Services/HypergridService/HypergridService.cs index 734931d..ac0f5ac 100644 --- a/OpenSim/Services/HypergridService/HypergridService.cs +++ b/OpenSim/Services/HypergridService/HypergridService.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Services.HypergridService | |||
51 | private static HypergridService m_RootInstance = null; | 51 | private static HypergridService m_RootInstance = null; |
52 | protected IConfigSource m_config; | 52 | protected IConfigSource m_config; |
53 | 53 | ||
54 | protected IAuthenticationService m_AuthenticationService = null; | 54 | protected IPresenceService m_PresenceService = null; |
55 | protected IGridService m_GridService; | 55 | protected IGridService m_GridService; |
56 | protected IAssetService m_AssetService; | 56 | protected IAssetService m_AssetService; |
57 | protected HypergridServiceConnector m_HypergridConnector; | 57 | protected HypergridServiceConnector m_HypergridConnector; |
@@ -94,7 +94,7 @@ namespace OpenSim.Services.HypergridService | |||
94 | if (gridConfig != null) | 94 | if (gridConfig != null) |
95 | { | 95 | { |
96 | string gridService = gridConfig.GetString("GridService", string.Empty); | 96 | string gridService = gridConfig.GetString("GridService", string.Empty); |
97 | string authService = gridConfig.GetString("AuthenticationService", String.Empty); | 97 | string presenceService = gridConfig.GetString("PresenceService", String.Empty); |
98 | string assetService = gridConfig.GetString("AssetService", string.Empty); | 98 | string assetService = gridConfig.GetString("AssetService", string.Empty); |
99 | 99 | ||
100 | Object[] args = new Object[] { config }; | 100 | Object[] args = new Object[] { config }; |
@@ -104,8 +104,8 @@ namespace OpenSim.Services.HypergridService | |||
104 | if (m_GridService == null) | 104 | if (m_GridService == null) |
105 | throw new Exception("HypergridService cannot function without a GridService"); | 105 | throw new Exception("HypergridService cannot function without a GridService"); |
106 | 106 | ||
107 | if (authService != String.Empty) | 107 | if (presenceService != String.Empty) |
108 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); | 108 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); |
109 | 109 | ||
110 | if (assetService != string.Empty) | 110 | if (assetService != string.Empty) |
111 | m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args); | 111 | m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args); |
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs index d41df75..59e0f82 100644 --- a/OpenSim/Services/Interfaces/IGatekeeperService.cs +++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs | |||
@@ -39,5 +39,8 @@ namespace OpenSim.Services.Interfaces | |||
39 | GridRegion GetHyperlinkRegion(UUID regionID); | 39 | GridRegion GetHyperlinkRegion(UUID regionID); |
40 | 40 | ||
41 | bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); | 41 | bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); |
42 | |||
43 | GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); | ||
44 | |||
42 | } | 45 | } |
43 | } | 46 | } |