SimProfile.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System.Xml;
  5. using System.Text;
  6. using libsecondlife;
  7. using Nwc.XmlRpc;
  8. namespace OpenSim.Framework.Sims
  9. {
  10. public class SimProfile : SimProfileBase
  11. {
  12. public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey)
  13. {
  14. try
  15. {
  16. Hashtable GridReqParams = new Hashtable();
  17. GridReqParams["region_handle"] = region_handle.ToString();
  18. GridReqParams["authkey"] = SendKey;
  19. ArrayList SendParams = new ArrayList();
  20. SendParams.Add(GridReqParams);
  21. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
  22. XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
  23. Hashtable RespData = (Hashtable)GridResp.Value;
  24. this.UUID = new LLUUID((string)RespData["UUID"]);
  25. this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
  26. this.regionname = (string)RespData["regionname"];
  27. this.sim_ip = (string)RespData["sim_ip"];
  28. this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
  29. this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
  30. this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
  31. this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
  32. this.sendkey = SendKey;
  33. this.recvkey = RecvKey;
  34. }
  35. catch (Exception e)
  36. {
  37. Console.WriteLine(e.ToString());
  38. }
  39. return this;
  40. }
  41. public SimProfile LoadFromGrid(LLUUID UUID, string GridURL, string SendKey, string RecvKey)
  42. {
  43. try
  44. {
  45. Hashtable GridReqParams = new Hashtable();
  46. GridReqParams["UUID"] = UUID.ToString();
  47. GridReqParams["authkey"] = SendKey;
  48. ArrayList SendParams = new ArrayList();
  49. SendParams.Add(GridReqParams);
  50. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
  51. XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
  52. Hashtable RespData = (Hashtable)GridResp.Value;
  53. this.UUID = new LLUUID((string)RespData["UUID"]);
  54. this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
  55. this.regionname = (string)RespData["regionname"];
  56. this.sim_ip = (string)RespData["sim_ip"];
  57. this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
  58. this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
  59. this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
  60. this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
  61. this.sendkey = SendKey;
  62. this.recvkey = RecvKey;
  63. }
  64. catch (Exception e)
  65. {
  66. Console.WriteLine(e.ToString());
  67. }
  68. return this;
  69. }
  70. public SimProfile()
  71. {
  72. }
  73. }
  74. }