RegionProfileData.cs 8.5 KB

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