SimProfile.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 System;
  29. using System.Collections.Generic;
  30. using System.Collections;
  31. using System.Xml;
  32. using System.Text;
  33. using libsecondlife;
  34. using Nwc.XmlRpc;
  35. namespace OpenSim.Framework.Sims
  36. {
  37. public class SimProfile : SimProfileBase
  38. {
  39. public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey)
  40. {
  41. try
  42. {
  43. Hashtable GridReqParams = new Hashtable();
  44. GridReqParams["region_handle"] = region_handle.ToString();
  45. GridReqParams["authkey"] = SendKey;
  46. ArrayList SendParams = new ArrayList();
  47. SendParams.Add(GridReqParams);
  48. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
  49. XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
  50. Hashtable RespData = (Hashtable)GridResp.Value;
  51. this.UUID = new LLUUID((string)RespData["UUID"]);
  52. this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
  53. this.regionname = (string)RespData["regionname"];
  54. this.sim_ip = (string)RespData["sim_ip"];
  55. this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
  56. this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
  57. this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
  58. this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
  59. this.sendkey = SendKey;
  60. this.recvkey = RecvKey;
  61. }
  62. catch (Exception e)
  63. {
  64. Console.WriteLine(e.ToString());
  65. }
  66. return this;
  67. }
  68. public SimProfile LoadFromGrid(LLUUID UUID, string GridURL, string SendKey, string RecvKey)
  69. {
  70. try
  71. {
  72. Hashtable GridReqParams = new Hashtable();
  73. GridReqParams["UUID"] = UUID.ToString();
  74. GridReqParams["authkey"] = SendKey;
  75. ArrayList SendParams = new ArrayList();
  76. SendParams.Add(GridReqParams);
  77. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
  78. XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
  79. Hashtable RespData = (Hashtable)GridResp.Value;
  80. this.UUID = new LLUUID((string)RespData["UUID"]);
  81. this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
  82. this.regionname = (string)RespData["regionname"];
  83. this.sim_ip = (string)RespData["sim_ip"];
  84. this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
  85. this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
  86. this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
  87. this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
  88. this.sendkey = SendKey;
  89. this.recvkey = RecvKey;
  90. }
  91. catch (Exception e)
  92. {
  93. Console.WriteLine(e.ToString());
  94. }
  95. return this;
  96. }
  97. public SimProfile()
  98. {
  99. }
  100. }
  101. }