diff options
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | 215 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs | 354 |
2 files changed, 215 insertions, 354 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index a8d9292..ae0a0b6 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -1,13 +1,18 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections; | 2 | using System.Collections; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using System.Drawing; | ||
4 | using System.Net; | 5 | using System.Net; |
6 | using System.Reflection; | ||
5 | 7 | ||
8 | using OpenSim.Framework; | ||
6 | using OpenSim.Services.Interfaces; | 9 | using OpenSim.Services.Interfaces; |
7 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 10 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
8 | 11 | ||
9 | using OpenMetaverse; | 12 | using OpenMetaverse; |
13 | using OpenMetaverse.Imaging; | ||
10 | using Nwc.XmlRpc; | 14 | using Nwc.XmlRpc; |
15 | using log4net; | ||
11 | 16 | ||
12 | using OpenSim.Services.Connectors.Simulation; | 17 | using OpenSim.Services.Connectors.Simulation; |
13 | 18 | ||
@@ -15,6 +20,21 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
15 | { | 20 | { |
16 | public class GatekeeperServiceConnector : SimulationServiceConnector | 21 | public class GatekeeperServiceConnector : SimulationServiceConnector |
17 | { | 22 | { |
23 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
24 | |||
25 | private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); | ||
26 | |||
27 | private IAssetService m_AssetService; | ||
28 | |||
29 | public GatekeeperServiceConnector() : base() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | public GatekeeperServiceConnector(IAssetService assService) | ||
34 | { | ||
35 | m_AssetService = assService; | ||
36 | } | ||
37 | |||
18 | protected override string AgentPath() | 38 | protected override string AgentPath() |
19 | { | 39 | { |
20 | return "/foreignagent/"; | 40 | return "/foreignagent/"; |
@@ -25,6 +45,201 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
25 | return "/foreignobject/"; | 45 | return "/foreignobject/"; |
26 | } | 46 | } |
27 | 47 | ||
48 | public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) | ||
49 | { | ||
50 | regionID = UUID.Zero; | ||
51 | imageURL = string.Empty; | ||
52 | realHandle = 0; | ||
53 | reason = string.Empty; | ||
54 | |||
55 | Hashtable hash = new Hashtable(); | ||
56 | hash["region_name"] = info.RegionName; | ||
57 | |||
58 | IList paramList = new ArrayList(); | ||
59 | paramList.Add(hash); | ||
60 | |||
61 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
62 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
63 | //m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + uri); | ||
64 | XmlRpcResponse response = null; | ||
65 | try | ||
66 | { | ||
67 | response = request.Send(uri, 10000); | ||
68 | } | ||
69 | catch (Exception e) | ||
70 | { | ||
71 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); | ||
72 | reason = "Error contacting remote server"; | ||
73 | return false; | ||
74 | } | ||
75 | |||
76 | if (response.IsFault) | ||
77 | { | ||
78 | reason = response.FaultString; | ||
79 | m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); | ||
80 | return false; | ||
81 | } | ||
82 | |||
83 | hash = (Hashtable)response.Value; | ||
84 | //foreach (Object o in hash) | ||
85 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
86 | try | ||
87 | { | ||
88 | bool success = false; | ||
89 | Boolean.TryParse((string)hash["result"], out success); | ||
90 | if (success) | ||
91 | { | ||
92 | UUID.TryParse((string)hash["uuid"], out regionID); | ||
93 | //m_log.Debug(">> HERE, uuid: " + uuid); | ||
94 | if ((string)hash["handle"] != null) | ||
95 | { | ||
96 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
97 | //m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
98 | } | ||
99 | if (hash["region_image"] != null) | ||
100 | { | ||
101 | imageURL = (string)hash["region_image"]; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | } | ||
106 | catch (Exception e) | ||
107 | { | ||
108 | reason = "Error parsing return arguments"; | ||
109 | m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | return true; | ||
114 | } | ||
115 | |||
116 | UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); | ||
117 | |||
118 | public UUID GetMapImage(UUID regionID, string imageURL) | ||
119 | { | ||
120 | if (m_AssetService == null) | ||
121 | return m_MissingTexture; | ||
122 | |||
123 | try | ||
124 | { | ||
125 | |||
126 | WebClient c = new WebClient(); | ||
127 | //m_log.Debug("JPEG: " + imageURL); | ||
128 | string filename = regionID.ToString(); | ||
129 | c.DownloadFile(imageURL, filename + ".jpg"); | ||
130 | Bitmap m = new Bitmap(filename + ".jpg"); | ||
131 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
132 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
133 | AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture); | ||
134 | |||
135 | // !!! for now | ||
136 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
137 | |||
138 | ass.Temporary = true; | ||
139 | ass.Local = true; | ||
140 | ass.Data = imageData; | ||
141 | |||
142 | m_AssetService.Store(ass); | ||
143 | |||
144 | // finally | ||
145 | return ass.FullID; | ||
146 | |||
147 | } | ||
148 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
149 | { | ||
150 | m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); | ||
151 | } | ||
152 | return UUID.Zero; | ||
153 | } | ||
154 | |||
155 | public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) | ||
156 | { | ||
157 | Hashtable hash = new Hashtable(); | ||
158 | hash["region_uuid"] = regionID.ToString(); | ||
159 | |||
160 | IList paramList = new ArrayList(); | ||
161 | paramList.Add(hash); | ||
162 | |||
163 | XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); | ||
164 | string uri = "http://" + gatekeeper.ExternalEndPoint.Address + ":" + gatekeeper.HttpPort + "/"; | ||
165 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + uri); | ||
166 | XmlRpcResponse response = null; | ||
167 | try | ||
168 | { | ||
169 | response = request.Send(uri, 10000); | ||
170 | } | ||
171 | catch (Exception e) | ||
172 | { | ||
173 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); | ||
174 | return null; | ||
175 | } | ||
176 | |||
177 | if (response.IsFault) | ||
178 | { | ||
179 | m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); | ||
180 | return null; | ||
181 | } | ||
182 | |||
183 | hash = (Hashtable)response.Value; | ||
184 | //foreach (Object o in hash) | ||
185 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
186 | try | ||
187 | { | ||
188 | bool success = false; | ||
189 | Boolean.TryParse((string)hash["result"], out success); | ||
190 | if (success) | ||
191 | { | ||
192 | GridRegion region = new GridRegion(); | ||
193 | |||
194 | UUID.TryParse((string)hash["uuid"], out region.RegionID); | ||
195 | //m_log.Debug(">> HERE, uuid: " + region.RegionID); | ||
196 | int n = 0; | ||
197 | if (hash["x"] != null) | ||
198 | { | ||
199 | Int32.TryParse((string)hash["x"], out n); | ||
200 | region.RegionLocX = n; | ||
201 | //m_log.Debug(">> HERE, x: " + region.RegionLocX); | ||
202 | } | ||
203 | if (hash["y"] != null) | ||
204 | { | ||
205 | Int32.TryParse((string)hash["y"], out n); | ||
206 | region.RegionLocY = n; | ||
207 | //m_log.Debug(">> HERE, y: " + region.RegionLocY); | ||
208 | } | ||
209 | if (hash["region_name"] != null) | ||
210 | { | ||
211 | region.RegionName = (string)hash["region_name"]; | ||
212 | //m_log.Debug(">> HERE, name: " + region.RegionName); | ||
213 | } | ||
214 | if (hash["hostname"] != null) | ||
215 | region.ExternalHostName = (string)hash["hostname"]; | ||
216 | if (hash["http_port"] != null) | ||
217 | { | ||
218 | uint p = 0; | ||
219 | UInt32.TryParse((string)hash["http_port"], out p); | ||
220 | region.HttpPort = p; | ||
221 | } | ||
222 | if (hash["internal_port"] != null) | ||
223 | { | ||
224 | int p = 0; | ||
225 | Int32.TryParse((string)hash["internal_port"], out p); | ||
226 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | ||
227 | } | ||
228 | |||
229 | // Successful return | ||
230 | return region; | ||
231 | } | ||
232 | |||
233 | } | ||
234 | catch (Exception e) | ||
235 | { | ||
236 | m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
237 | return null; | ||
238 | } | ||
239 | |||
240 | return null; | ||
241 | } | ||
242 | |||
28 | public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt) | 243 | public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt) |
29 | { | 244 | { |
30 | position = Vector3.UnitY; lookAt = Vector3.UnitY; | 245 | position = Vector3.UnitY; lookAt = Vector3.UnitY; |
diff --git a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs deleted file mode 100644 index 1786d38..0000000 --- a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs +++ /dev/null | |||
@@ -1,354 +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 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Drawing; | ||
33 | using System.Net; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
37 | |||
38 | using OpenSim.Framework; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.Imaging; | ||
42 | using log4net; | ||
43 | using Nwc.XmlRpc; | ||
44 | using Nini.Config; | ||
45 | |||
46 | namespace OpenSim.Services.Connectors.Hypergrid | ||
47 | { | ||
48 | public class HypergridServiceConnector : IHypergridService | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private IAssetService m_AssetService; | ||
53 | private string m_ServerURL; | ||
54 | |||
55 | public HypergridServiceConnector() { } | ||
56 | |||
57 | public HypergridServiceConnector(IAssetService assService) | ||
58 | { | ||
59 | m_AssetService = assService; | ||
60 | } | ||
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 | |||
87 | public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) | ||
88 | { | ||
89 | regionID = UUID.Zero; | ||
90 | imageURL = string.Empty; | ||
91 | realHandle = 0; | ||
92 | reason = string.Empty; | ||
93 | |||
94 | Hashtable hash = new Hashtable(); | ||
95 | hash["region_name"] = info.RegionName; | ||
96 | |||
97 | IList paramList = new ArrayList(); | ||
98 | paramList.Add(hash); | ||
99 | |||
100 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
101 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
102 | //m_log.Debug("[HGrid]: Linking to " + uri); | ||
103 | XmlRpcResponse response = null; | ||
104 | try | ||
105 | { | ||
106 | response = request.Send(uri, 10000); | ||
107 | } | ||
108 | catch (Exception e) | ||
109 | { | ||
110 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
111 | reason = "Error contacting remote server"; | ||
112 | return false; | ||
113 | } | ||
114 | |||
115 | if (response.IsFault) | ||
116 | { | ||
117 | reason = response.FaultString; | ||
118 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
119 | return false; | ||
120 | } | ||
121 | |||
122 | hash = (Hashtable)response.Value; | ||
123 | //foreach (Object o in hash) | ||
124 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
125 | try | ||
126 | { | ||
127 | bool success = false; | ||
128 | Boolean.TryParse((string)hash["result"], out success); | ||
129 | if (success) | ||
130 | { | ||
131 | UUID.TryParse((string)hash["uuid"], out regionID); | ||
132 | //m_log.Debug(">> HERE, uuid: " + uuid); | ||
133 | if ((string)hash["handle"] != null) | ||
134 | { | ||
135 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
136 | //m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
137 | } | ||
138 | if (hash["region_image"] != null) | ||
139 | { | ||
140 | imageURL = (string)hash["region_image"]; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | } | ||
145 | catch (Exception e) | ||
146 | { | ||
147 | reason = "Error parsing return arguments"; | ||
148 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
149 | return false; | ||
150 | } | ||
151 | |||
152 | return true; | ||
153 | } | ||
154 | |||
155 | public UUID GetMapImage(UUID regionID, string imageURL) | ||
156 | { | ||
157 | try | ||
158 | { | ||
159 | |||
160 | WebClient c = new WebClient(); | ||
161 | //m_log.Debug("JPEG: " + uri); | ||
162 | string filename = regionID.ToString(); | ||
163 | c.DownloadFile(imageURL, filename + ".jpg"); | ||
164 | Bitmap m = new Bitmap(filename + ".jpg"); | ||
165 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
166 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
167 | AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture); | ||
168 | |||
169 | // !!! for now | ||
170 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
171 | |||
172 | ass.Temporary = true; | ||
173 | ass.Local = true; | ||
174 | ass.Data = imageData; | ||
175 | |||
176 | m_AssetService.Store(ass); | ||
177 | |||
178 | // finally | ||
179 | return ass.FullID; | ||
180 | |||
181 | } | ||
182 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
183 | { | ||
184 | m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); | ||
185 | } | ||
186 | return UUID.Zero; | ||
187 | } | ||
188 | |||
189 | public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) | ||
190 | { | ||
191 | Hashtable hash = new Hashtable(); | ||
192 | hash["region_uuid"] = regionID.ToString(); | ||
193 | |||
194 | IList paramList = new ArrayList(); | ||
195 | paramList.Add(hash); | ||
196 | |||
197 | XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); | ||
198 | string uri = "http://" + gatekeeper.ExternalEndPoint.Address + ":" + gatekeeper.HttpPort + "/"; | ||
199 | m_log.Debug("[HGrid]: contacting " + uri); | ||
200 | XmlRpcResponse response = null; | ||
201 | try | ||
202 | { | ||
203 | response = request.Send(uri, 10000); | ||
204 | } | ||
205 | catch (Exception e) | ||
206 | { | ||
207 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
208 | return null; | ||
209 | } | ||
210 | |||
211 | if (response.IsFault) | ||
212 | { | ||
213 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
214 | return null; | ||
215 | } | ||
216 | |||
217 | hash = (Hashtable)response.Value; | ||
218 | //foreach (Object o in hash) | ||
219 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
220 | try | ||
221 | { | ||
222 | bool success = false; | ||
223 | Boolean.TryParse((string)hash["result"], out success); | ||
224 | if (success) | ||
225 | { | ||
226 | GridRegion region = new GridRegion(); | ||
227 | |||
228 | UUID.TryParse((string)hash["uuid"], out region.RegionID); | ||
229 | //m_log.Debug(">> HERE, uuid: " + region.RegionID); | ||
230 | int n = 0; | ||
231 | if (hash["x"] != null) | ||
232 | { | ||
233 | Int32.TryParse((string)hash["x"], out n); | ||
234 | region.RegionLocX = n; | ||
235 | //m_log.Debug(">> HERE, x: " + region.RegionLocX); | ||
236 | } | ||
237 | if (hash["y"] != null) | ||
238 | { | ||
239 | Int32.TryParse((string)hash["y"], out n); | ||
240 | region.RegionLocY = n; | ||
241 | //m_log.Debug(">> HERE, y: " + region.RegionLocY); | ||
242 | } | ||
243 | if (hash["region_name"] != null) | ||
244 | { | ||
245 | region.RegionName = (string)hash["region_name"]; | ||
246 | //m_log.Debug(">> HERE, name: " + region.RegionName); | ||
247 | } | ||
248 | if (hash["hostname"] != null) | ||
249 | region.ExternalHostName = (string)hash["hostname"]; | ||
250 | if (hash["http_port"] != null) | ||
251 | { | ||
252 | uint p = 0; | ||
253 | UInt32.TryParse((string)hash["http_port"], out p); | ||
254 | region.HttpPort = p; | ||
255 | } | ||
256 | if (hash["internal_port"] != null) | ||
257 | { | ||
258 | int p = 0; | ||
259 | Int32.TryParse((string)hash["internal_port"], out p); | ||
260 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | ||
261 | } | ||
262 | |||
263 | // Successful return | ||
264 | return region; | ||
265 | } | ||
266 | |||
267 | } | ||
268 | catch (Exception e) | ||
269 | { | ||
270 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
271 | return null; | ||
272 | } | ||
273 | |||
274 | return null; | ||
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 | ||
353 | } | ||
354 | } | ||