UserManager.cs 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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;
  30. using Nwc.XmlRpc;
  31. using OpenSim.Framework.Data;
  32. using OpenSim.Framework.UserManagement;
  33. namespace OpenSim.Grid.UserServer
  34. {
  35. public class UserManager : UserManagerBase
  36. {
  37. public UserManager()
  38. {
  39. }
  40. /// <summary>
  41. /// Customises the login response and fills in missing values.
  42. /// </summary>
  43. /// <param name="response">The existing response</param>
  44. /// <param name="theUser">The user profile</param>
  45. public override void CustomiseResponse( LoginResponse response, UserProfileData theUser)
  46. {
  47. // Load information from the gridserver
  48. SimProfileData SimInfo = new SimProfileData();
  49. SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
  50. // Customise the response
  51. // Home Location
  52. response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " +
  53. "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
  54. "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
  55. // Destination
  56. Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
  57. response.SimAddress = SimInfo.serverIP;
  58. response.SimPort = (Int32)SimInfo.serverPort;
  59. response.RegionX = SimInfo.regionLocX;
  60. response.RegionY = SimInfo.regionLocX;
  61. // Notify the target of an incoming user
  62. Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI+ ")");
  63. // Prepare notification
  64. Hashtable SimParams = new Hashtable();
  65. SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
  66. SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
  67. SimParams["firstname"] = theUser.username;
  68. SimParams["lastname"] = theUser.surname;
  69. SimParams["agent_id"] = theUser.UUID.ToString();
  70. SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
  71. SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
  72. SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
  73. SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
  74. SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
  75. ArrayList SendParams = new ArrayList();
  76. SendParams.Add(SimParams);
  77. // Update agent with target sim
  78. theUser.currentAgent.currentRegion = SimInfo.UUID;
  79. theUser.currentAgent.currentHandle = SimInfo.regionHandle;
  80. System.Console.WriteLine("sending reply");
  81. // Send
  82. XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
  83. XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 3000);
  84. }
  85. }
  86. }