diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | 119 |
1 files changed, 119 insertions, 0 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 | } | ||