diff options
Diffstat (limited to 'OpenSim/Framework/Data/RegionProfileData.cs')
-rw-r--r-- | OpenSim/Framework/Data/RegionProfileData.cs | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/OpenSim/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs new file mode 100644 index 0000000..5e5dac6 --- /dev/null +++ b/OpenSim/Framework/Data/RegionProfileData.cs | |||
@@ -0,0 +1,192 @@ | |||
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 OpenSim 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 libsecondlife; | ||
29 | using Nwc.XmlRpc; | ||
30 | |||
31 | using System; | ||
32 | using System.Collections; | ||
33 | |||
34 | namespace OpenSim.Framework.Data | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// A class which contains information known to the grid server about a region | ||
38 | /// </summary> | ||
39 | public class RegionProfileData | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// The name of the region | ||
43 | /// </summary> | ||
44 | public string regionName = ""; | ||
45 | |||
46 | /// <summary> | ||
47 | /// A 64-bit number combining map position into a (mostly) unique ID | ||
48 | /// </summary> | ||
49 | public ulong regionHandle; | ||
50 | |||
51 | /// <summary> | ||
52 | /// OGS/OpenSim Specific ID for a region | ||
53 | /// </summary> | ||
54 | public LLUUID UUID; | ||
55 | |||
56 | /// <summary> | ||
57 | /// Coordinates of the region | ||
58 | /// </summary> | ||
59 | public uint regionLocX; | ||
60 | public uint regionLocY; | ||
61 | public uint regionLocZ; // Reserved (round-robin, layers, etc) | ||
62 | |||
63 | /// <summary> | ||
64 | /// Authentication secrets | ||
65 | /// </summary> | ||
66 | /// <remarks>Not very secure, needs improvement.</remarks> | ||
67 | public string regionSendKey = ""; | ||
68 | public string regionRecvKey = ""; | ||
69 | public string regionSecret = ""; | ||
70 | |||
71 | /// <summary> | ||
72 | /// Whether the region is online | ||
73 | /// </summary> | ||
74 | public bool regionOnline; | ||
75 | |||
76 | /// <summary> | ||
77 | /// Information about the server that the region is currently hosted on | ||
78 | /// </summary> | ||
79 | public string serverIP = ""; | ||
80 | public uint serverPort; | ||
81 | public string serverURI = ""; | ||
82 | |||
83 | public uint httpPort; | ||
84 | public uint remotingPort; | ||
85 | public string httpServerURI = ""; | ||
86 | |||
87 | /// <summary> | ||
88 | /// Set of optional overrides. Can be used to create non-eulicidean spaces. | ||
89 | /// </summary> | ||
90 | public ulong regionNorthOverrideHandle; | ||
91 | public ulong regionSouthOverrideHandle; | ||
92 | public ulong regionEastOverrideHandle; | ||
93 | public ulong regionWestOverrideHandle; | ||
94 | |||
95 | /// <summary> | ||
96 | /// Optional: URI Location of the region database | ||
97 | /// </summary> | ||
98 | /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks> | ||
99 | public string regionDataURI = ""; | ||
100 | |||
101 | /// <summary> | ||
102 | /// Region Asset Details | ||
103 | /// </summary> | ||
104 | public string regionAssetURI = ""; | ||
105 | public string regionAssetSendKey = ""; | ||
106 | public string regionAssetRecvKey = ""; | ||
107 | |||
108 | /// <summary> | ||
109 | /// Region Userserver Details | ||
110 | /// </summary> | ||
111 | public string regionUserURI = ""; | ||
112 | public string regionUserSendKey = ""; | ||
113 | public string regionUserRecvKey = ""; | ||
114 | |||
115 | /// <summary> | ||
116 | /// Region Map Texture Asset | ||
117 | /// </summary> | ||
118 | public LLUUID regionMapTextureID = new LLUUID("00000000-0000-0000-9999-000000000006"); | ||
119 | |||
120 | /// <summary> | ||
121 | /// Get Sim profile data from grid server when in grid mode | ||
122 | /// </summary> | ||
123 | /// <param name="region_uuid"></param> | ||
124 | /// <param name="gridserver_url"></param> | ||
125 | /// <param name="?"></param> | ||
126 | /// <returns></returns> | ||
127 | public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey) | ||
128 | { | ||
129 | Hashtable requestData = new Hashtable(); | ||
130 | requestData["region_uuid"] = region_uuid.UUID.ToString(); | ||
131 | requestData["authkey"] = gridserver_sendkey; | ||
132 | ArrayList SendParams = new ArrayList(); | ||
133 | SendParams.Add(requestData); | ||
134 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
135 | XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); | ||
136 | |||
137 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
138 | |||
139 | if (responseData.ContainsKey("error")) | ||
140 | { | ||
141 | return null; | ||
142 | } | ||
143 | |||
144 | RegionProfileData simData = new RegionProfileData(); | ||
145 | simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
146 | simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
147 | simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256)); | ||
148 | simData.serverIP = (string)responseData["sim_ip"]; | ||
149 | simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); | ||
150 | simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); | ||
151 | simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
152 | simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/"; | ||
153 | simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; | ||
154 | simData.UUID = new LLUUID((string)responseData["region_UUID"]); | ||
155 | simData.regionName = (string)responseData["region_name"]; | ||
156 | |||
157 | return simData; | ||
158 | } | ||
159 | public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey) | ||
160 | { | ||
161 | Hashtable requestData = new Hashtable(); | ||
162 | requestData["region_handle"] = region_handle.ToString(); | ||
163 | requestData["authkey"] = gridserver_sendkey; | ||
164 | ArrayList SendParams = new ArrayList(); | ||
165 | SendParams.Add(requestData); | ||
166 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
167 | XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); | ||
168 | |||
169 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
170 | |||
171 | if (responseData.ContainsKey("error")) | ||
172 | { | ||
173 | return null; | ||
174 | } | ||
175 | |||
176 | RegionProfileData simData = new RegionProfileData(); | ||
177 | simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
178 | simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
179 | simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256)); | ||
180 | simData.serverIP = (string)responseData["sim_ip"]; | ||
181 | simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); | ||
182 | simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); | ||
183 | simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
184 | simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; | ||
185 | simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/"; | ||
186 | simData.UUID = new LLUUID((string)responseData["region_UUID"]); | ||
187 | simData.regionName = (string)responseData["region_name"]; | ||
188 | |||
189 | return simData; | ||
190 | } | ||
191 | } | ||
192 | } | ||