diff options
author | lbsa71 | 2009-02-12 10:21:21 +0000 |
---|---|---|
committer | lbsa71 | 2009-02-12 10:21:21 +0000 |
commit | 61878884569f9c01b6324f9a9d9fbcac7034f536 (patch) | |
tree | 1871310b7bb4d4463feb5f456123305101090096 /OpenSim/Data/RegionProfileServiceProxy.cs | |
parent | * Turned RegionProfileService non-static (diff) | |
download | opensim-SC-61878884569f9c01b6324f9a9d9fbcac7034f536.zip opensim-SC-61878884569f9c01b6324f9a9d9fbcac7034f536.tar.gz opensim-SC-61878884569f9c01b6324f9a9d9fbcac7034f536.tar.bz2 opensim-SC-61878884569f9c01b6324f9a9d9fbcac7034f536.tar.xz |
* Renamed RegionProfileService to RegionProfileServiceProxy to better reflect actual use.
* Added IRegionProfileService
Diffstat (limited to 'OpenSim/Data/RegionProfileServiceProxy.cs')
-rw-r--r-- | OpenSim/Data/RegionProfileServiceProxy.cs | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/OpenSim/Data/RegionProfileServiceProxy.cs b/OpenSim/Data/RegionProfileServiceProxy.cs new file mode 100644 index 0000000..54e392a --- /dev/null +++ b/OpenSim/Data/RegionProfileServiceProxy.cs | |||
@@ -0,0 +1,94 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | using Nwc.XmlRpc; | ||
6 | using OpenMetaverse; | ||
7 | using OpenSim.Framework; | ||
8 | |||
9 | namespace OpenSim.Data | ||
10 | { | ||
11 | public class RegionProfileServiceProxy : IRegionProfileService | ||
12 | { | ||
13 | /// <summary> | ||
14 | /// Request sim data based on arbitrary key/value | ||
15 | /// </summary> | ||
16 | private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue) | ||
17 | { | ||
18 | Hashtable requestData = new Hashtable(); | ||
19 | requestData[keyField] = keyValue; | ||
20 | requestData["authkey"] = gridserverSendkey; | ||
21 | ArrayList SendParams = new ArrayList(); | ||
22 | SendParams.Add(requestData); | ||
23 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
24 | XmlRpcResponse GridResp = GridReq.Send(gridserverUrl.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="regionId">The region UUID to look for</param> | ||
55 | /// <param name="gridserverUrl"></param> | ||
56 | /// <param name="gridserverSendkey"></param> | ||
57 | /// <param name="gridserverRecvkey"></param> | ||
58 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
59 | /// <remarks>This method should be statics</remarks> | ||
60 | public RegionProfileData RequestSimProfileData(UUID regionId, Uri gridserverUrl, | ||
61 | string gridserverSendkey, string gridserverRecvkey) | ||
62 | { | ||
63 | return RequestSimData(gridserverUrl, gridserverSendkey, "region_UUID", regionId.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 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="regionName">the region name to look for</param> | ||
84 | /// <param name="gridserverUrl"></param> | ||
85 | /// <param name="gridserverSendkey"></param> | ||
86 | /// <param name="gridserverRecvkey"></param> | ||
87 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
88 | public RegionProfileData RequestSimProfileData(string regionName, Uri gridserverUrl, | ||
89 | string gridserverSendkey, string gridserverRecvkey) | ||
90 | { | ||
91 | return RequestSimData(gridserverUrl, gridserverSendkey, "region_name_search", regionName ); | ||
92 | } | ||
93 | } | ||
94 | } | ||