SimProfileData.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Copyright (c) Contributors, http://www.openmetaverse.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. using System;
  31. using System.Collections;
  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 SimProfileData
  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 SimProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
  113. {
  114. Hashtable requestData = new Hashtable();
  115. requestData["region_uuid"] = region_uuid.UUID.ToString();
  116. requestData["authkey"] = gridserver_sendkey;
  117. ArrayList SendParams = new ArrayList();
  118. SendParams.Add(requestData);
  119. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
  120. XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
  121. Hashtable responseData = (Hashtable)GridResp.Value;
  122. if (responseData.ContainsKey("error"))
  123. {
  124. return null;
  125. }
  126. SimProfileData simData = new SimProfileData();
  127. simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
  128. simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
  129. simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
  130. simData.serverIP = (string)responseData["sim_ip"];
  131. simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
  132. simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
  133. simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
  134. simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
  135. simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
  136. simData.UUID = new LLUUID((string)responseData["region_UUID"]);
  137. simData.regionName = (string)responseData["region_name"];
  138. return simData;
  139. }
  140. public SimProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey)
  141. {
  142. Hashtable requestData = new Hashtable();
  143. requestData["region_handle"] = region_handle.ToString();
  144. requestData["authkey"] = gridserver_sendkey;
  145. ArrayList SendParams = new ArrayList();
  146. SendParams.Add(requestData);
  147. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
  148. XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
  149. Hashtable responseData = (Hashtable)GridResp.Value;
  150. if (responseData.ContainsKey("error"))
  151. {
  152. return null;
  153. }
  154. SimProfileData simData = new SimProfileData();
  155. simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
  156. simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
  157. simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256));
  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.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
  163. simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/";
  164. simData.UUID = new LLUUID((string)responseData["region_UUID"]);
  165. simData.regionName = (string)responseData["region_name"];
  166. return simData;
  167. }
  168. }
  169. }