RegionProfileData.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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. using System;
  28. using System.Collections;
  29. using OpenMetaverse;
  30. using Nwc.XmlRpc;
  31. using OpenSim.Framework;
  32. namespace OpenSim.Data
  33. {
  34. /// <summary>
  35. /// A class which contains information known to the grid server about a region
  36. /// </summary>
  37. [Serializable]
  38. public class RegionProfileData
  39. {
  40. /// <summary>
  41. /// The name of the region
  42. /// </summary>
  43. public string regionName = String.Empty;
  44. /// <summary>
  45. /// A 64-bit number combining map position into a (mostly) unique ID
  46. /// </summary>
  47. public ulong regionHandle;
  48. /// <summary>
  49. /// OGS/OpenSim Specific ID for a region
  50. /// </summary>
  51. public UUID UUID;
  52. /// <summary>
  53. /// Coordinates of the region
  54. /// </summary>
  55. public uint regionLocX;
  56. public uint regionLocY;
  57. public uint regionLocZ; // Reserved (round-robin, layers, etc)
  58. /// <summary>
  59. /// Authentication secrets
  60. /// </summary>
  61. /// <remarks>Not very secure, needs improvement.</remarks>
  62. public string regionSendKey = String.Empty;
  63. public string regionRecvKey = String.Empty;
  64. public string regionSecret = String.Empty;
  65. /// <summary>
  66. /// Whether the region is online
  67. /// </summary>
  68. public bool regionOnline;
  69. /// <summary>
  70. /// Information about the server that the region is currently hosted on
  71. /// </summary>
  72. public string serverIP = String.Empty;
  73. public uint serverPort;
  74. public string serverURI = String.Empty;
  75. public uint httpPort;
  76. public uint remotingPort;
  77. public string httpServerURI = String.Empty;
  78. /// <summary>
  79. /// Set of optional overrides. Can be used to create non-eulicidean spaces.
  80. /// </summary>
  81. public ulong regionNorthOverrideHandle;
  82. public ulong regionSouthOverrideHandle;
  83. public ulong regionEastOverrideHandle;
  84. public ulong regionWestOverrideHandle;
  85. /// <summary>
  86. /// Optional: URI Location of the region database
  87. /// </summary>
  88. /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
  89. public string regionDataURI = String.Empty;
  90. /// <summary>
  91. /// Region Asset Details
  92. /// </summary>
  93. public string regionAssetURI = String.Empty;
  94. public string regionAssetSendKey = String.Empty;
  95. public string regionAssetRecvKey = String.Empty;
  96. /// <summary>
  97. /// Region Userserver Details
  98. /// </summary>
  99. public string regionUserURI = String.Empty;
  100. public string regionUserSendKey = String.Empty;
  101. public string regionUserRecvKey = String.Empty;
  102. /// <summary>
  103. /// Region Map Texture Asset
  104. /// </summary>
  105. public UUID regionMapTextureID = new UUID("00000000-0000-1111-9999-000000000006");
  106. /// <summary>
  107. /// this particular mod to the file provides support within the spec for RegionProfileData for the
  108. /// owner_uuid for the region
  109. /// </summary>
  110. public UUID owner_uuid = UUID.Zero;
  111. /// <summary>
  112. /// OGS/OpenSim Specific original ID for a region after move/split
  113. /// </summary>
  114. public UUID originUUID;
  115. /// <summary>
  116. /// Request sim data based on arbitrary key/value
  117. /// </summary>
  118. private static RegionProfileData RequestSimData(Uri gridserver_url, string gridserver_sendkey, string keyField, string keyValue)
  119. {
  120. Hashtable requestData = new Hashtable();
  121. requestData[keyField] = keyValue;
  122. requestData["authkey"] = gridserver_sendkey;
  123. ArrayList SendParams = new ArrayList();
  124. SendParams.Add(requestData);
  125. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
  126. XmlRpcResponse GridResp = GridReq.Send(gridserver_url.ToString(), 3000);
  127. Hashtable responseData = (Hashtable) GridResp.Value;
  128. RegionProfileData simData = null;
  129. if (!responseData.ContainsKey("error"))
  130. {
  131. simData = new RegionProfileData();
  132. simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]);
  133. simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]);
  134. simData.regionHandle =
  135. Utils.UIntsToLong((simData.regionLocX * Constants.RegionSize),
  136. (simData.regionLocY*Constants.RegionSize));
  137. simData.serverIP = (string) responseData["sim_ip"];
  138. simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
  139. simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
  140. simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
  141. simData.serverURI = (string) responseData["server_uri"];
  142. simData.httpServerURI = "http://" + (string)responseData["sim_ip"] + ":" + simData.httpPort.ToString() + "/";
  143. simData.UUID = new UUID((string) responseData["region_UUID"]);
  144. simData.regionName = (string) responseData["region_name"];
  145. }
  146. return simData;
  147. }
  148. /// <summary>
  149. /// Request sim profile information from a grid server, by Region UUID
  150. /// </summary>
  151. /// <param name="region_UUID">The region UUID to look for</param>
  152. /// <param name="gridserver_url"></param>
  153. /// <param name="gridserver_sendkey"></param>
  154. /// <param name="gridserver_recvkey"></param>
  155. /// <returns>The sim profile. Null if there was a request failure</returns>
  156. /// <remarks>This method should be statics</remarks>
  157. public static RegionProfileData RequestSimProfileData(UUID region_uuid, Uri gridserver_url,
  158. string gridserver_sendkey, string gridserver_recvkey)
  159. {
  160. return RequestSimData(gridserver_url, gridserver_sendkey, "region_UUID", region_uuid.Guid.ToString());
  161. }
  162. /// <summary>
  163. /// Request sim profile information from a grid server, by Region Handle
  164. /// </summary>
  165. /// <param name="region_handle">the region handle to look for</param>
  166. /// <param name="gridserver_url"></param>
  167. /// <param name="gridserver_sendkey"></param>
  168. /// <param name="gridserver_recvkey"></param>
  169. /// <returns>The sim profile. Null if there was a request failure</returns>
  170. public static RegionProfileData RequestSimProfileData(ulong region_handle, Uri gridserver_url,
  171. string gridserver_sendkey, string gridserver_recvkey)
  172. {
  173. return RequestSimData(gridserver_url, gridserver_sendkey, "region_handle", region_handle.ToString());
  174. }
  175. /// <summary>
  176. /// Request sim profile information from a grid server, by Region Name
  177. /// </summary>
  178. /// <param name="region_handle">the region name to look for</param>
  179. /// <param name="gridserver_url"></param>
  180. /// <param name="gridserver_sendkey"></param>
  181. /// <param name="gridserver_recvkey"></param>
  182. /// <returns>The sim profile. Null if there was a request failure</returns>
  183. public static RegionProfileData RequestSimProfileData(string regionName, Uri gridserver_url,
  184. string gridserver_sendkey, string gridserver_recvkey)
  185. {
  186. return RequestSimData(gridserver_url, gridserver_sendkey, "region_name_search", regionName );
  187. }
  188. //Data Wrappers
  189. public string RegionName
  190. {
  191. get { return regionName; }
  192. set { regionName = value; }
  193. }
  194. public ulong RegionHandle
  195. {
  196. get { return regionHandle; }
  197. set { regionHandle = value; }
  198. }
  199. public UUID Uuid
  200. {
  201. get { return UUID; }
  202. set { UUID = value; }
  203. }
  204. public uint RegionLocX
  205. {
  206. get { return regionLocX; }
  207. set { regionLocX = value; }
  208. }
  209. public uint RegionLocY
  210. {
  211. get { return regionLocY; }
  212. set { regionLocY = value; }
  213. }
  214. public uint RegionLocZ
  215. {
  216. get { return regionLocZ; }
  217. set { regionLocZ = value; }
  218. }
  219. public string RegionSendKey
  220. {
  221. get { return regionSendKey; }
  222. set { regionSendKey = value; }
  223. }
  224. public string RegionRecvKey
  225. {
  226. get { return regionRecvKey; }
  227. set { regionRecvKey = value; }
  228. }
  229. public string RegionSecret
  230. {
  231. get { return regionSecret; }
  232. set { regionSecret = value; }
  233. }
  234. public bool RegionOnline
  235. {
  236. get { return regionOnline; }
  237. set { regionOnline = value; }
  238. }
  239. public string ServerIP
  240. {
  241. get { return serverIP; }
  242. set { serverIP = value; }
  243. }
  244. public uint ServerPort
  245. {
  246. get { return serverPort; }
  247. set { serverPort = value; }
  248. }
  249. public string ServerURI
  250. {
  251. get { return serverURI; }
  252. set { serverURI = value; }
  253. }
  254. public uint ServerHttpPort
  255. {
  256. get { return httpPort; }
  257. set { httpPort = value; }
  258. }
  259. public uint ServerRemotingPort
  260. {
  261. get { return remotingPort; }
  262. set { remotingPort = value; }
  263. }
  264. public ulong NorthOverrideHandle
  265. {
  266. get { return regionNorthOverrideHandle; }
  267. set { regionNorthOverrideHandle = value; }
  268. }
  269. public ulong SouthOverrideHandle
  270. {
  271. get { return regionSouthOverrideHandle; }
  272. set { regionSouthOverrideHandle = value; }
  273. }
  274. public ulong EastOverrideHandle
  275. {
  276. get { return regionEastOverrideHandle; }
  277. set { regionEastOverrideHandle = value; }
  278. }
  279. public ulong WestOverrideHandle
  280. {
  281. get { return regionWestOverrideHandle; }
  282. set { regionWestOverrideHandle = value; }
  283. }
  284. public string RegionDataURI
  285. {
  286. get { return regionDataURI; }
  287. set { regionDataURI = value; }
  288. }
  289. public string RegionAssetURI
  290. {
  291. get { return regionAssetURI; }
  292. set { regionAssetURI = value; }
  293. }
  294. public string RegionAssetSendKey
  295. {
  296. get { return regionAssetSendKey; }
  297. set { regionAssetSendKey = value; }
  298. }
  299. public string RegionAssetRecvKey
  300. {
  301. get { return regionAssetRecvKey; }
  302. set { regionAssetRecvKey = value; }
  303. }
  304. public string RegionUserURI
  305. {
  306. get { return regionUserURI; }
  307. set { regionUserURI = value; }
  308. }
  309. public string RegionUserSendKey
  310. {
  311. get { return regionUserSendKey; }
  312. set { regionUserSendKey = value; }
  313. }
  314. public string RegionUserRecvKey
  315. {
  316. get { return regionUserRecvKey; }
  317. set { regionUserRecvKey = value; }
  318. }
  319. public UUID RegionMapTextureID
  320. {
  321. get { return regionMapTextureID; }
  322. set { regionMapTextureID = value; }
  323. }
  324. public UUID Owner_uuid
  325. {
  326. get { return owner_uuid; }
  327. set { owner_uuid = value; }
  328. }
  329. public UUID OriginUUID
  330. {
  331. get { return originUUID; }
  332. set { originUUID = value; }
  333. }
  334. }
  335. }