aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/RegionProfileService.cs
diff options
context:
space:
mode:
authorlbsa712009-02-12 10:05:15 +0000
committerlbsa712009-02-12 10:05:15 +0000
commitfa796308c39be2666bfae00238cf9d29cb4b9e03 (patch)
treedcd07cedf4538d9e68314217c6c361c2e12be7da /OpenSim/Data/RegionProfileService.cs
parent* optimized usings. (diff)
downloadopensim-SC_OLD-fa796308c39be2666bfae00238cf9d29cb4b9e03.zip
opensim-SC_OLD-fa796308c39be2666bfae00238cf9d29cb4b9e03.tar.gz
opensim-SC_OLD-fa796308c39be2666bfae00238cf9d29cb4b9e03.tar.bz2
opensim-SC_OLD-fa796308c39be2666bfae00238cf9d29cb4b9e03.tar.xz
* Added RegionProfileService and moved RequestSimData to it.
Diffstat (limited to 'OpenSim/Data/RegionProfileService.cs')
-rw-r--r--OpenSim/Data/RegionProfileService.cs94
1 files changed, 94 insertions, 0 deletions
diff --git a/OpenSim/Data/RegionProfileService.cs b/OpenSim/Data/RegionProfileService.cs
new file mode 100644
index 0000000..1a73ed1
--- /dev/null
+++ b/OpenSim/Data/RegionProfileService.cs
@@ -0,0 +1,94 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using Nwc.XmlRpc;
6using OpenMetaverse;
7using OpenSim.Framework;
8
9namespace OpenSim.Data
10{
11 public class RegionProfileService
12 {
13 /// <summary>
14 /// Request sim data based on arbitrary key/value
15 /// </summary>
16 private static RegionProfileData RequestSimData(Uri gridserver_url, string gridserver_sendkey, string keyField, string keyValue)
17 {
18 Hashtable requestData = new Hashtable();
19 requestData[keyField] = keyValue;
20 requestData["authkey"] = gridserver_sendkey;
21 ArrayList SendParams = new ArrayList();
22 SendParams.Add(requestData);
23 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
24 XmlRpcResponse GridResp = GridReq.Send(gridserver_url.ToString(), 3000);
25
26 Hashtable responseData = (Hashtable) GridResp.Value;
27
28 RegionProfileData simData = null;
29
30 if (!responseData.ContainsKey("error"))
31 {
32 simData = new RegionProfileData();
33 simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]);
34 simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]);
35 simData.regionHandle =
36 Utils.UIntsToLong((simData.regionLocX * Constants.RegionSize),
37 (simData.regionLocY*Constants.RegionSize));
38 simData.serverIP = (string) responseData["sim_ip"];
39 simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
40 simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
41 simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
42 simData.serverURI = (string) responseData["server_uri"];
43 simData.httpServerURI = "http://" + (string)responseData["sim_ip"] + ":" + simData.httpPort.ToString() + "/";
44 simData.UUID = new UUID((string) responseData["region_UUID"]);
45 simData.regionName = (string) responseData["region_name"];
46 }
47
48 return simData;
49 }
50
51 /// <summary>
52 /// Request sim profile information from a grid server, by Region UUID
53 /// </summary>
54 /// <param name="region_UUID">The region UUID to look for</param>
55 /// <param name="gridserver_url"></param>
56 /// <param name="gridserver_sendkey"></param>
57 /// <param name="gridserver_recvkey"></param>
58 /// <returns>The sim profile. Null if there was a request failure</returns>
59 /// <remarks>This method should be statics</remarks>
60 public static RegionProfileData RequestSimProfileData(UUID region_uuid, Uri gridserver_url,
61 string gridserver_sendkey, string gridserver_recvkey)
62 {
63 return RequestSimData(gridserver_url, gridserver_sendkey, "region_UUID", region_uuid.Guid.ToString());
64 }
65
66 /// <summary>
67 /// Request sim profile information from a grid server, by Region Handle
68 /// </summary>
69 /// <param name="region_handle">the region handle to look for</param>
70 /// <param name="gridserver_url"></param>
71 /// <param name="gridserver_sendkey"></param>
72 /// <param name="gridserver_recvkey"></param>
73 /// <returns>The sim profile. Null if there was a request failure</returns>
74 public static RegionProfileData RequestSimProfileData(ulong region_handle, Uri gridserver_url,
75 string gridserver_sendkey, string gridserver_recvkey)
76 {
77 return RequestSimData(gridserver_url, gridserver_sendkey, "region_handle", region_handle.ToString());
78 }
79
80 /// <summary>
81 /// Request sim profile information from a grid server, by Region Name
82 /// </summary>
83 /// <param name="region_handle">the region name to look for</param>
84 /// <param name="gridserver_url"></param>
85 /// <param name="gridserver_sendkey"></param>
86 /// <param name="gridserver_recvkey"></param>
87 /// <returns>The sim profile. Null if there was a request failure</returns>
88 public static RegionProfileData RequestSimProfileData(string regionName, Uri gridserver_url,
89 string gridserver_sendkey, string gridserver_recvkey)
90 {
91 return RequestSimData(gridserver_url, gridserver_sendkey, "region_name_search", regionName );
92 }
93 }
94}