IGridUserService.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 OpenSimulator 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. using System;
  28. using System.Collections.Generic;
  29. using OpenMetaverse;
  30. namespace OpenSim.Services.Interfaces
  31. {
  32. /// <summary>
  33. /// Records user information specific to a grid but which is not part of a user's account.
  34. /// </summary>
  35. public class GridUserInfo
  36. {
  37. public string UserID;
  38. public UUID HomeRegionID;
  39. public Vector3 HomePosition;
  40. public Vector3 HomeLookAt;
  41. public UUID LastRegionID;
  42. public Vector3 LastPosition;
  43. public Vector3 LastLookAt;
  44. public bool Online;
  45. public DateTime Login;
  46. public DateTime Logout;
  47. public GridUserInfo() {}
  48. public GridUserInfo(Dictionary<string, object> kvp)
  49. {
  50. if (kvp.ContainsKey("UserID"))
  51. UserID = kvp["UserID"].ToString();
  52. if (kvp.ContainsKey("HomeRegionID"))
  53. UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID);
  54. if (kvp.ContainsKey("HomePosition"))
  55. Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition);
  56. if (kvp.ContainsKey("HomeLookAt"))
  57. Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt);
  58. if (kvp.ContainsKey("LastRegionID"))
  59. UUID.TryParse(kvp["LastRegionID"].ToString(), out LastRegionID);
  60. if (kvp.ContainsKey("LastPosition"))
  61. Vector3.TryParse(kvp["LastPosition"].ToString(), out LastPosition);
  62. if (kvp.ContainsKey("LastLookAt"))
  63. Vector3.TryParse(kvp["LastLookAt"].ToString(), out LastLookAt);
  64. if (kvp.ContainsKey("Login"))
  65. DateTime.TryParse(kvp["Login"].ToString(), out Login);
  66. if (kvp.ContainsKey("Logout"))
  67. DateTime.TryParse(kvp["Logout"].ToString(), out Logout);
  68. if (kvp.ContainsKey("Online"))
  69. Boolean.TryParse(kvp["Online"].ToString(), out Online);
  70. }
  71. public virtual Dictionary<string, object> ToKeyValuePairs()
  72. {
  73. Dictionary<string, object> result = new Dictionary<string, object>();
  74. result["UserID"] = UserID;
  75. result["HomeRegionID"] = HomeRegionID.ToString();
  76. result["HomePosition"] = HomePosition.ToString();
  77. result["HomeLookAt"] = HomeLookAt.ToString();
  78. result["LastRegionID"] = LastRegionID.ToString();
  79. result["LastPosition"] = LastPosition.ToString();
  80. result["LastLookAt"] = LastLookAt.ToString();
  81. result["Online"] = Online.ToString();
  82. result["Login"] = Login.ToString();
  83. result["Logout"] = Logout.ToString();
  84. return result;
  85. }
  86. }
  87. public interface IGridUserService
  88. {
  89. GridUserInfo LoggedIn(string userID);
  90. /// <summary>
  91. /// Informs the grid that a user is logged out and to remove any session data for them
  92. /// </summary>
  93. /// <param name="userID">Ignore if your connector does not use userID for logouts</param>
  94. /// <param name="sessionID">Ignore if your connector does not use sessionID for logouts</param>
  95. /// <param name="regionID">RegionID where the user was last located</param>
  96. /// <param name="lastPosition">Last region-relative position of the user</param>
  97. /// <param name="lastLookAt">Last normalized look direction for the user</param>
  98. /// <returns>True if the logout request was successfully processed, otherwise false</returns>
  99. bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
  100. bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt);
  101. /// <summary>
  102. /// Stores the last known user position at the grid level
  103. /// </summary>
  104. /// <param name="userID">Ignore if your connector does not use userID for position updates</param>
  105. /// <param name="sessionID">Ignore if your connector does not use sessionID for position updates</param>
  106. /// <param name="regionID">RegionID where the user is currently located</param>
  107. /// <param name="lastPosition">Region-relative position</param>
  108. /// <param name="lastLookAt">Normalized look direction</param>
  109. /// <returns>True if the user's last position was successfully updated, otherwise false</returns>
  110. bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
  111. GridUserInfo GetGridUserInfo(string userID);
  112. GridUserInfo[] GetGridUserInfo(string[] userID);
  113. }
  114. }