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