aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Clients/GridClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Clients/GridClient.cs')
-rw-r--r--OpenSim/Framework/Communications/Clients/GridClient.cs389
1 files changed, 0 insertions, 389 deletions
diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs
deleted file mode 100644
index 0198d75..0000000
--- a/OpenSim/Framework/Communications/Clients/GridClient.cs
+++ /dev/null
@@ -1,389 +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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33
34using log4net;
35using OpenMetaverse;
36using Nwc.XmlRpc;
37
38namespace OpenSim.Framework.Communications.Clients
39{
40 public class GridClient
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 public bool RegisterRegion(
45 string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines)
46 {
47 m_log.InfoFormat(
48 "[GRID CLIENT]: Registering region {0} with grid at {1}", regionInfo.RegionName, gridServerURL);
49
50 forcefulBanLines = true;
51
52 Hashtable GridParams = new Hashtable();
53 // Login / Authentication
54
55 GridParams["authkey"] = sendKey;
56 GridParams["recvkey"] = receiveKey;
57 GridParams["UUID"] = regionInfo.RegionID.ToString();
58 GridParams["sim_ip"] = regionInfo.ExternalHostName;
59 GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
60 GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
61 GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
62 GridParams["sim_name"] = regionInfo.RegionName;
63 GridParams["http_port"] = regionInfo.HttpPort.ToString();
64 GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
65 GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString();
66 GridParams["originUUID"] = regionInfo.originRegionID.ToString();
67 GridParams["server_uri"] = regionInfo.ServerURI;
68 GridParams["region_secret"] = regionInfo.regionSecret;
69 GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString();
70
71 GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString();
72
73 // Package into an XMLRPC Request
74 ArrayList SendParams = new ArrayList();
75 SendParams.Add(GridParams);
76
77 // Send Request
78 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
79 XmlRpcResponse GridResp;
80
81 try
82 {
83 // The timeout should always be significantly larger than the timeout for the grid server to request
84 // the initial status of the region before confirming registration.
85 GridResp = GridReq.Send(gridServerURL, 90000);
86 }
87 catch (Exception e)
88 {
89 Exception e2
90 = new Exception(
91 String.Format(
92 "Unable to register region with grid at {0}. Grid service not running?",
93 gridServerURL),
94 e);
95
96 throw e2;
97 }
98
99 Hashtable GridRespData = (Hashtable)GridResp.Value;
100 // Hashtable griddatahash = GridRespData;
101
102 // Process Response
103 if (GridRespData.ContainsKey("error"))
104 {
105 string errorstring = (string)GridRespData["error"];
106
107 Exception e = new Exception(
108 String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring));
109
110 throw e;
111 }
112 else
113 {
114 // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY);
115 if (GridRespData.ContainsKey("allow_forceful_banlines"))
116 {
117 if ((string)GridRespData["allow_forceful_banlines"] != "TRUE")
118 {
119 forcefulBanLines = false;
120 }
121 }
122
123 }
124 return true;
125 }
126
127 public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg)
128 {
129 errorMsg = "";
130 Hashtable GridParams = new Hashtable();
131
132 GridParams["UUID"] = regionInfo.RegionID.ToString();
133
134 // Package into an XMLRPC Request
135 ArrayList SendParams = new ArrayList();
136 SendParams.Add(GridParams);
137
138 // Send Request
139 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams);
140 XmlRpcResponse GridResp = null;
141
142 try
143 {
144 GridResp = GridReq.Send(gridServerURL, 10000);
145 }
146 catch (Exception e)
147 {
148 Exception e2
149 = new Exception(
150 String.Format(
151 "Unable to deregister region with grid at {0}. Grid service not running?",
152 gridServerURL),
153 e);
154
155 throw e2;
156 }
157
158 Hashtable GridRespData = (Hashtable)GridResp.Value;
159
160 // Hashtable griddatahash = GridRespData;
161
162 // Process Response
163 if (GridRespData != null && GridRespData.ContainsKey("error"))
164 {
165 errorMsg = (string)GridRespData["error"];
166 return false;
167 }
168
169 return true;
170 }
171
172 public bool RequestNeighborInfo(
173 string gridServerURL, string sendKey, string receiveKey, UUID regionUUID,
174 out RegionInfo regionInfo, out string errorMsg)
175 {
176 // didn't find it so far, we have to go the long way
177 regionInfo = null;
178 errorMsg = string.Empty;
179 Hashtable requestData = new Hashtable();
180 requestData["region_UUID"] = regionUUID.ToString();
181 requestData["authkey"] = sendKey;
182 ArrayList SendParams = new ArrayList();
183 SendParams.Add(requestData);
184 XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams);
185 XmlRpcResponse gridResp = null;
186
187 try
188 {
189 gridResp = gridReq.Send(gridServerURL, 3000);
190 }
191 catch (Exception e)
192 {
193 errorMsg = e.Message;
194 return false;
195 }
196
197 Hashtable responseData = (Hashtable)gridResp.Value;
198
199 if (responseData.ContainsKey("error"))
200 {
201 errorMsg = (string)responseData["error"];
202 return false; ;
203 }
204
205 regionInfo = BuildRegionInfo(responseData, String.Empty);
206
207 return true;
208 }
209
210 public bool RequestNeighborInfo(
211 string gridServerURL, string sendKey, string receiveKey, ulong regionHandle,
212 out RegionInfo regionInfo, out string errorMsg)
213 {
214 // didn't find it so far, we have to go the long way
215 regionInfo = null;
216 errorMsg = string.Empty;
217
218 try
219 {
220 Hashtable requestData = new Hashtable();
221 requestData["region_handle"] = regionHandle.ToString();
222 requestData["authkey"] = sendKey;
223 ArrayList SendParams = new ArrayList();
224 SendParams.Add(requestData);
225 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
226 XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000);
227
228 Hashtable responseData = (Hashtable)GridResp.Value;
229
230 if (responseData.ContainsKey("error"))
231 {
232 errorMsg = (string)responseData["error"];
233 return false;
234 }
235
236 uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
237 uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
238 string externalHostName = (string)responseData["sim_ip"];
239 uint simPort = Convert.ToUInt32(responseData["sim_port"]);
240 string regionName = (string)responseData["region_name"];
241 UUID regionID = new UUID((string)responseData["region_UUID"]);
242 uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
243
244 uint httpPort = 9000;
245 if (responseData.ContainsKey("http_port"))
246 {
247 httpPort = Convert.ToUInt32((string)responseData["http_port"]);
248 }
249
250 // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info?
251
252 string simURI = "http://" + externalHostName + ":" + simPort;
253
254 // string externalUri = (string) responseData["sim_uri"];
255
256 //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
257 regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI);
258 }
259 catch (Exception e)
260 {
261 errorMsg = e.Message;
262 return false;
263 }
264
265 return true;
266 }
267
268 public bool RequestClosestRegion(
269 string gridServerURL, string sendKey, string receiveKey, string regionName,
270 out RegionInfo regionInfo, out string errorMsg)
271 {
272 regionInfo = null;
273 errorMsg = string.Empty;
274 try
275 {
276 Hashtable requestData = new Hashtable();
277 requestData["region_name_search"] = regionName;
278 requestData["authkey"] = sendKey;
279 ArrayList SendParams = new ArrayList();
280 SendParams.Add(requestData);
281 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
282 XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000);
283
284 Hashtable responseData = (Hashtable)GridResp.Value;
285
286 if (responseData.ContainsKey("error"))
287 {
288 errorMsg = (string)responseData["error"];
289 return false;
290 }
291
292 regionInfo = BuildRegionInfo(responseData, "");
293
294 }
295 catch (Exception e)
296 {
297 errorMsg = e.Message;
298 return false;
299 }
300 return true;
301 }
302
303 /// <summary>
304 /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
305 /// </summary>
306 /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
307 /// <param name="minX">Minimum X value</param>
308 /// <param name="minY">Minimum Y value</param>
309 /// <param name="maxX">Maximum X value</param>
310 /// <param name="maxY">Maximum Y value</param>
311 /// <returns>Hashtable of hashtables containing map data elements</returns>
312 public bool MapBlockQuery(
313 string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg)
314 {
315 respData = new Hashtable();
316 errorMsg = string.Empty;
317
318 Hashtable param = new Hashtable();
319 param["xmin"] = minX;
320 param["ymin"] = minY;
321 param["xmax"] = maxX;
322 param["ymax"] = maxY;
323 IList parameters = new ArrayList();
324 parameters.Add(param);
325
326 try
327 {
328 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
329 XmlRpcResponse resp = req.Send(gridServerURL, 10000);
330 respData = (Hashtable)resp.Value;
331 return true;
332 }
333 catch (Exception e)
334 {
335 errorMsg = e.Message;
336 return false;
337 }
338 }
339
340 public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg)
341 {
342 respData = null;
343 errorMsg = string.Empty;
344 try
345 {
346 XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters);
347 XmlRpcResponse resp = request.Send(gridServerURL, 10000);
348 respData = (Hashtable)resp.Value;
349 if (respData != null && respData.Contains("faultCode"))
350 {
351 errorMsg = (string)respData["faultString"];
352 return false;
353 }
354
355 return true;
356 }
357 catch (Exception e)
358 {
359 errorMsg = e.Message;
360 return false;
361 }
362 }
363
364 public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix)
365 {
366 uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]);
367 uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]);
368 string internalIpStr = (string)responseData[prefix + "sim_ip"];
369 uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]);
370
371 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port);
372
373 RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
374 regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]);
375 regionInfo.RemotingAddress = internalIpStr;
376
377 if (responseData.ContainsKey(prefix + "http_port"))
378 {
379 regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]);
380 }
381
382 regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]);
383 regionInfo.RegionName = (string)responseData[prefix + "region_name"];
384
385 regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]);
386 return regionInfo;
387 }
388 }
389}