diff options
author | lbsa71 | 2008-07-29 19:52:58 +0000 |
---|---|---|
committer | lbsa71 | 2008-07-29 19:52:58 +0000 |
commit | 8edab95bad417a4d82cdfb6e9ef3138e8c5f0ab1 (patch) | |
tree | f711c63ba64fea7489189c8d859977115022ac7f /OpenSim/Data/RegionProfileData.cs | |
parent | * minor: temporarily command out variables to prevent compile warnings (diff) | |
download | opensim-SC-8edab95bad417a4d82cdfb6e9ef3138e8c5f0ab1.zip opensim-SC-8edab95bad417a4d82cdfb6e9ef3138e8c5f0ab1.tar.gz opensim-SC-8edab95bad417a4d82cdfb6e9ef3138e8c5f0ab1.tar.bz2 opensim-SC-8edab95bad417a4d82cdfb6e9ef3138e8c5f0ab1.tar.xz |
* Refactored some heavily duplicated RequestSimProfileData functions
* Changed InventoryUrl and GridServerURL type to Uri instead of string - to address '/' issues.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/RegionProfileData.cs | 127 |
1 files changed, 40 insertions, 87 deletions
diff --git a/OpenSim/Data/RegionProfileData.cs b/OpenSim/Data/RegionProfileData.cs index 12f3927..f6172b9 100644 --- a/OpenSim/Data/RegionProfileData.cs +++ b/OpenSim/Data/RegionProfileData.cs | |||
@@ -130,51 +130,60 @@ namespace OpenSim.Data | |||
130 | /// </summary> | 130 | /// </summary> |
131 | public LLUUID originUUID; | 131 | public LLUUID originUUID; |
132 | 132 | ||
133 | |||
134 | /// <summary> | 133 | /// <summary> |
135 | /// Request sim profile information from a grid server, by Region UUID | 134 | /// Request sim data based on arbitrary key/value |
136 | /// </summary> | 135 | /// </summary> |
137 | /// <param name="region_uuid">The region UUID to look for</param> | 136 | private static RegionProfileData RequestSimData(Uri gridserver_url, string gridserver_sendkey, string keyField, string keyValue) |
138 | /// <param name="gridserver_url"></param> | ||
139 | /// <param name="gridserver_sendkey"></param> | ||
140 | /// <param name="gridserver_recvkey"></param> | ||
141 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
142 | /// <remarks>This method should be statics</remarks> | ||
143 | public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, | ||
144 | string gridserver_sendkey, string gridserver_recvkey) | ||
145 | { | 137 | { |
146 | Hashtable requestData = new Hashtable(); | 138 | Hashtable requestData = new Hashtable(); |
147 | requestData["region_uuid"] = region_uuid.UUID.ToString(); | 139 | requestData[keyField] = keyValue; |
148 | requestData["authkey"] = gridserver_sendkey; | 140 | requestData["authkey"] = gridserver_sendkey; |
149 | ArrayList SendParams = new ArrayList(); | 141 | ArrayList SendParams = new ArrayList(); |
150 | SendParams.Add(requestData); | 142 | SendParams.Add(requestData); |
151 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | 143 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); |
152 | XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); | 144 | XmlRpcResponse GridResp = GridReq.Send(gridserver_url.ToString(), 3000); |
153 | 145 | ||
154 | Hashtable responseData = (Hashtable) GridResp.Value; | 146 | Hashtable responseData = (Hashtable) GridResp.Value; |
155 | 147 | ||
156 | if (responseData.ContainsKey("error")) | 148 | RegionProfileData simData = null; |
149 | |||
150 | if (!responseData.ContainsKey("error")) | ||
157 | { | 151 | { |
158 | return null; | 152 | simData = new RegionProfileData(); |
153 | simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); | ||
154 | simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); | ||
155 | simData.regionHandle = | ||
156 | Helpers.UIntsToLong((simData.regionLocX*Constants.RegionSize), | ||
157 | (simData.regionLocY*Constants.RegionSize)); | ||
158 | simData.serverIP = (string) responseData["sim_ip"]; | ||
159 | simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); | ||
160 | simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); | ||
161 | simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); | ||
162 | simData.serverURI = (string) responseData["server_uri"]; | ||
163 | simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; | ||
164 | simData.UUID = new LLUUID((string) responseData["region_UUID"]); | ||
165 | simData.regionName = (string) responseData["region_name"]; | ||
159 | } | 166 | } |
160 | 167 | ||
161 | RegionProfileData simData = new RegionProfileData(); | ||
162 | simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); | ||
163 | simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); | ||
164 | simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); | ||
165 | simData.serverIP = (string) responseData["sim_ip"]; | ||
166 | simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); | ||
167 | simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); | ||
168 | simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); | ||
169 | simData.serverURI = (string)responseData["server_uri"]; | ||
170 | simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; | ||
171 | simData.UUID = new LLUUID((string) responseData["region_UUID"]); | ||
172 | simData.regionName = (string) responseData["region_name"]; | ||
173 | |||
174 | return simData; | 168 | return simData; |
175 | } | 169 | } |
176 | 170 | ||
177 | /// <summary> | 171 | /// <summary> |
172 | /// Request sim profile information from a grid server, by Region UUID | ||
173 | /// </summary> | ||
174 | /// <param name="region_uuid">The region UUID to look for</param> | ||
175 | /// <param name="gridserver_url"></param> | ||
176 | /// <param name="gridserver_sendkey"></param> | ||
177 | /// <param name="gridserver_recvkey"></param> | ||
178 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
179 | /// <remarks>This method should be statics</remarks> | ||
180 | public static RegionProfileData RequestSimProfileData(LLUUID region_uuid, Uri gridserver_url, | ||
181 | string gridserver_sendkey, string gridserver_recvkey) | ||
182 | { | ||
183 | return RequestSimData(gridserver_url, gridserver_sendkey, "region_uuid", region_uuid.UUID.ToString()); | ||
184 | } | ||
185 | |||
186 | /// <summary> | ||
178 | /// Request sim profile information from a grid server, by Region Handle | 187 | /// Request sim profile information from a grid server, by Region Handle |
179 | /// </summary> | 188 | /// </summary> |
180 | /// <param name="region_handle">the region handle to look for</param> | 189 | /// <param name="region_handle">the region handle to look for</param> |
@@ -182,38 +191,10 @@ namespace OpenSim.Data | |||
182 | /// <param name="gridserver_sendkey"></param> | 191 | /// <param name="gridserver_sendkey"></param> |
183 | /// <param name="gridserver_recvkey"></param> | 192 | /// <param name="gridserver_recvkey"></param> |
184 | /// <returns>The sim profile. Null if there was a request failure</returns> | 193 | /// <returns>The sim profile. Null if there was a request failure</returns> |
185 | public static RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, | 194 | public static RegionProfileData RequestSimProfileData(ulong region_handle, Uri gridserver_url, |
186 | string gridserver_sendkey, string gridserver_recvkey) | 195 | string gridserver_sendkey, string gridserver_recvkey) |
187 | { | 196 | { |
188 | Hashtable requestData = new Hashtable(); | 197 | return RequestSimData(gridserver_url, gridserver_sendkey, "region_handle", region_handle.ToString()); |
189 | requestData["region_handle"] = region_handle.ToString(); | ||
190 | requestData["authkey"] = gridserver_sendkey; | ||
191 | ArrayList SendParams = new ArrayList(); | ||
192 | SendParams.Add(requestData); | ||
193 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
194 | XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); | ||
195 | |||
196 | Hashtable responseData = (Hashtable) GridResp.Value; | ||
197 | |||
198 | if (responseData.ContainsKey("error")) | ||
199 | { | ||
200 | return null; | ||
201 | } | ||
202 | |||
203 | RegionProfileData simData = new RegionProfileData(); | ||
204 | simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); | ||
205 | simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); | ||
206 | simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); | ||
207 | simData.serverIP = (string) responseData["sim_ip"]; | ||
208 | simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); | ||
209 | simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); | ||
210 | simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); | ||
211 | simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; | ||
212 | simData.serverURI = (string)responseData["server_uri"]; | ||
213 | simData.UUID = new LLUUID((string) responseData["region_UUID"]); | ||
214 | simData.regionName = (string) responseData["region_name"]; | ||
215 | |||
216 | return simData; | ||
217 | } | 198 | } |
218 | 199 | ||
219 | /// <summary> | 200 | /// <summary> |
@@ -224,38 +205,10 @@ namespace OpenSim.Data | |||
224 | /// <param name="gridserver_sendkey"></param> | 205 | /// <param name="gridserver_sendkey"></param> |
225 | /// <param name="gridserver_recvkey"></param> | 206 | /// <param name="gridserver_recvkey"></param> |
226 | /// <returns>The sim profile. Null if there was a request failure</returns> | 207 | /// <returns>The sim profile. Null if there was a request failure</returns> |
227 | public static RegionProfileData RequestSimProfileData(string regionName, string gridserver_url, | 208 | public static RegionProfileData RequestSimProfileData(string regionName, Uri gridserver_url, |
228 | string gridserver_sendkey, string gridserver_recvkey) | 209 | string gridserver_sendkey, string gridserver_recvkey) |
229 | { | 210 | { |
230 | Hashtable requestData = new Hashtable(); | 211 | return RequestSimData(gridserver_url, gridserver_sendkey, "region_name_search", regionName ); |
231 | requestData["region_name_search"] = regionName; | ||
232 | requestData["authkey"] = gridserver_sendkey; | ||
233 | ArrayList SendParams = new ArrayList(); | ||
234 | SendParams.Add(requestData); | ||
235 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
236 | XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); | ||
237 | |||
238 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
239 | |||
240 | if (responseData.ContainsKey("error")) | ||
241 | { | ||
242 | return null; | ||
243 | } | ||
244 | |||
245 | RegionProfileData simData = new RegionProfileData(); | ||
246 | simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
247 | simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
248 | simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); | ||
249 | simData.serverIP = (string)responseData["sim_ip"]; | ||
250 | simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); | ||
251 | simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); | ||
252 | simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
253 | simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; | ||
254 | simData.serverURI = (string)responseData["server_uri"]; | ||
255 | simData.UUID = new LLUUID((string)responseData["region_UUID"]); | ||
256 | simData.regionName = (string)responseData["region_name"]; | ||
257 | |||
258 | return simData; | ||
259 | } | 212 | } |
260 | } | 213 | } |
261 | } | 214 | } |