PageRenderTime 156ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/Aurora/Framework/Services/IAgentInfoService.cs

https://bitbucket.org/VirtualReality/software-testing
C# | 211 lines | 82 code | 27 blank | 102 comment | 2 complexity | c638d948d733195d7f8cf617cd7e2b40 MD5 | raw file
  1. /*
  2. * Copyright (c) Contributors, http://aurora-sim.org/, 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 Aurora-Sim 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 Nini.Config;
  30. using OpenMetaverse;
  31. using OpenMetaverse.StructuredData;
  32. namespace Aurora.Framework
  33. {
  34. public class UserInfo : IDataTransferable
  35. {
  36. public Vector3 CurrentLookAt;
  37. public Vector3 CurrentPosition;
  38. /// <summary>
  39. /// The region the user is currently active in
  40. /// </summary>
  41. public UUID CurrentRegionID;
  42. public string CurrentRegionURI;
  43. public Vector3 HomeLookAt;
  44. public Vector3 HomePosition;
  45. /// <summary>
  46. /// The home region of this user
  47. /// </summary>
  48. public UUID HomeRegionID;
  49. /// <summary>
  50. /// Any other assorted into about this user
  51. /// </summary>
  52. public OSDMap Info = new OSDMap();
  53. /// <summary>
  54. /// Whether this agent is currently online
  55. /// </summary>
  56. public bool IsOnline;
  57. /// <summary>
  58. /// The last login of the user
  59. /// </summary>
  60. public DateTime LastLogin;
  61. /// <summary>
  62. /// The last logout of the user
  63. /// </summary>
  64. public DateTime LastLogout;
  65. /// <summary>
  66. /// The user that this info is for
  67. /// </summary>
  68. public string UserID;
  69. public override OSDMap ToOSD()
  70. {
  71. OSDMap retVal = new OSDMap();
  72. retVal["UserID"] = UserID;
  73. retVal["CurrentRegionID"] = CurrentRegionID;
  74. retVal["CurrentRegionURI"] = CurrentRegionURI;
  75. retVal["CurrentPosition"] = CurrentPosition;
  76. retVal["CurrentLookAt"] = CurrentLookAt;
  77. retVal["HomeRegionID"] = HomeRegionID;
  78. retVal["HomePosition"] = HomePosition;
  79. retVal["HomeLookAt"] = HomeLookAt;
  80. retVal["IsOnline"] = IsOnline;
  81. retVal["LastLogin"] = LastLogin;
  82. retVal["LastLogout"] = LastLogout;
  83. retVal["Info"] = Info;
  84. return retVal;
  85. }
  86. public override void FromOSD(OSDMap retVal)
  87. {
  88. UserID = retVal["UserID"].AsString();
  89. CurrentRegionID = retVal["CurrentRegionID"].AsUUID();
  90. CurrentRegionURI = retVal["CurrentRegionURI"].AsString();
  91. CurrentPosition = retVal["CurrentPosition"].AsVector3();
  92. CurrentLookAt = retVal["CurrentLookAt"].AsVector3();
  93. HomeRegionID = retVal["HomeRegionID"].AsUUID();
  94. HomePosition = retVal["HomePosition"].AsVector3();
  95. HomeLookAt = retVal["HomeLookAt"].AsVector3();
  96. IsOnline = retVal["IsOnline"].AsBoolean();
  97. LastLogin = retVal["LastLogin"].AsDate();
  98. LastLogout = retVal["LastLogout"].AsDate();
  99. if (retVal["Info"].Type == OSDType.Map)
  100. Info = (OSDMap) retVal["Info"];
  101. }
  102. }
  103. public interface IAgentInfoService
  104. {
  105. /// <summary>
  106. /// The local service (if one exists)
  107. /// </summary>
  108. IAgentInfoService InnerService { get; }
  109. /// <summary>
  110. /// Get the user infos for the given user
  111. /// </summary>
  112. /// <param name = "userID"></param>
  113. /// <param name = "regionID"></param>
  114. /// <returns></returns>
  115. UserInfo GetUserInfo(string userID);
  116. /// <summary>
  117. /// Get the user infos for the given users
  118. /// </summary>
  119. /// <param name = "userID"></param>
  120. /// <param name = "regionID"></param>
  121. /// <returns></returns>
  122. List<UserInfo> GetUserInfos(List<string> userIDs);
  123. /// <summary>
  124. /// Gets a list of userinfos that are logged into the given region
  125. /// </summary>
  126. /// <param name="regionID"></param>
  127. /// <returns></returns>
  128. List<UserInfo> GetUserInfos(UUID regionID);
  129. /// <summary>
  130. /// Get the HTTP URLs for all root agents of the given users
  131. /// </summary>
  132. /// <param name = "requestor"></param>
  133. /// <param name = "userIDs"></param>
  134. /// <returns></returns>
  135. List<string> GetAgentsLocations(string requestor, List<string> userIDs);
  136. /// <summary>
  137. /// Set the home position of the given user
  138. /// </summary>
  139. /// <param name = "userID"></param>
  140. /// <param name = "homeID"></param>
  141. /// <param name = "homePosition"></param>
  142. /// <param name = "homeLookAt"></param>
  143. /// <returns></returns>
  144. bool SetHomePosition(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt);
  145. /// <summary>
  146. /// Set the last known position of the given user
  147. /// </summary>
  148. /// <param name = "userID"></param>
  149. /// <param name = "regionID"></param>
  150. /// <param name = "lastPosition"></param>
  151. /// <param name = "lastLookAt"></param>
  152. void SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt, string regionURI);
  153. /// <summary>
  154. /// Log the agent in or out
  155. /// </summary>
  156. /// <param name = "userID"></param>
  157. /// <param name = "loggingIn">Whether the user is logging in or out</param>
  158. /// <param name = "fireLoggedInEvent">Fire the event to log a user in</param>
  159. /// <param name = "enteringRegion">The region the user is entering (if logging in)</param>
  160. /// <param name = "enteringRegion">The regionURI the user is entering (if logging in)</param>
  161. void SetLoggedIn(string userID, bool loggingIn, UUID enteringRegion, string enteringRegionURI);
  162. /// <summary>
  163. /// Fire the status changed event for this user
  164. /// </summary>
  165. /// <param name="userID"></param>
  166. /// <param name="loggingIn"></param>
  167. /// <param name="enteringRegion"></param>
  168. void FireUserStatusChangeEvent(string userID, bool loggingIn, UUID enteringRegion);
  169. void Start(IConfigSource config, IRegistryCore registry);
  170. void FinishedStartup();
  171. void Initialize(IConfigSource config, IRegistryCore registry);
  172. }
  173. public interface IAgentInfoConnector : IAuroraDataPlugin
  174. {
  175. bool Set(UserInfo info);
  176. void Update(string userID, Dictionary<string, object> values);
  177. void SetLastPosition(string userID, UUID regionID, string regionURI, Vector3 Position, Vector3 LookAt);
  178. void SetHomePosition(string userID, UUID regionID, Vector3 Position, Vector3 LookAt);
  179. UserInfo Get(string userID, bool checkOnlineStatus, out bool onlineStatusChanged);
  180. uint RecentlyOnline(uint secondsAgo, bool stillOnline);
  181. List<UserInfo> RecentlyOnline(uint secondsAgo, bool stillOnline, Dictionary<string, bool> sort, uint start, uint count);
  182. List<UserInfo> GetByCurrentRegion(string regionID);
  183. }
  184. }