aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserAccountService/GridUserService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/UserAccountService/GridUserService.cs')
-rw-r--r--OpenSim/Services/UserAccountService/GridUserService.cs80
1 files changed, 66 insertions, 14 deletions
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index bef1691..e4bcf15 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -43,19 +43,58 @@ namespace OpenSim.Services.UserAccountService
43 public class GridUserService : GridUserServiceBase, IGridUserService 43 public class GridUserService : GridUserServiceBase, IGridUserService
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static bool m_Initialized;
46 47
47 public GridUserService(IConfigSource config) : base(config) 48 public GridUserService(IConfigSource config) : base(config)
48 { 49 {
49 m_log.Debug("[GRID USER SERVICE]: Starting user grid service"); 50 m_log.Debug("[GRID USER SERVICE]: Starting user grid service");
50 51
51 MainConsole.Instance.Commands.AddCommand( 52 if (!m_Initialized)
52 "Users", false, 53 {
53 "show grid users online", 54 m_Initialized = true;
54 "show grid users online", 55
55 "Show number of grid users registered as online.", 56 MainConsole.Instance.Commands.AddCommand(
56 "This number may not be accurate as a region may crash or not be cleanly shutdown and leave grid users shown as online\n." 57 "Users", false,
57 + "For this reason, users online for more than 5 days are not currently counted", 58 "show grid user",
58 HandleShowGridUsersOnline); 59 "show grid user <ID>",
60 "Show grid user entry or entries that match or start with the given ID. This will normally be a UUID.",
61 "This is for debug purposes to see what data is found for a particular user id.",
62 HandleShowGridUser);
63
64 MainConsole.Instance.Commands.AddCommand(
65 "Users", false,
66 "show grid users online",
67 "show grid users online",
68 "Show number of grid users registered as online.",
69 "This number may not be accurate as a region may crash or not be cleanly shutdown and leave grid users shown as online\n."
70 + "For this reason, users online for more than 5 days are not currently counted",
71 HandleShowGridUsersOnline);
72 }
73 }
74
75 protected void HandleShowGridUser(string module, string[] cmdparams)
76 {
77 if (cmdparams.Length != 4)
78 {
79 MainConsole.Instance.Output("Usage: show grid user <UUID>");
80 return;
81 }
82
83 GridUserData[] data = m_Database.GetAll(cmdparams[3]);
84
85 foreach (GridUserData gu in data)
86 {
87 ConsoleDisplayList cdl = new ConsoleDisplayList();
88
89 cdl.AddRow("User ID", gu.UserID);
90
91 foreach (KeyValuePair<string,string> kvp in gu.Data)
92 cdl.AddRow(kvp.Key, kvp.Value);
93
94 MainConsole.Instance.Output(cdl.ToString());
95 }
96
97 MainConsole.Instance.OutputFormat("Entries: {0}", data.Length);
59 } 98 }
60 99
61 protected void HandleShowGridUsersOnline(string module, string[] cmdparams) 100 protected void HandleShowGridUsersOnline(string module, string[] cmdparams)
@@ -87,11 +126,13 @@ namespace OpenSim.Services.UserAccountService
87 MainConsole.Instance.OutputFormat("Users online: {0}", onlineRecentlyCount); 126 MainConsole.Instance.OutputFormat("Users online: {0}", onlineRecentlyCount);
88 } 127 }
89 128
90 public virtual GridUserInfo GetGridUserInfo(string userID) 129 private GridUserData GetGridUserData(string userID)
91 { 130 {
92 GridUserData d = null; 131 GridUserData d = null;
93 if (userID.Length > 36) // it's a UUI 132 if (userID.Length > 36) // it's a UUI
133 {
94 d = m_Database.Get(userID); 134 d = m_Database.Get(userID);
135 }
95 else // it's a UUID 136 else // it's a UUID
96 { 137 {
97 GridUserData[] ds = m_Database.GetAll(userID); 138 GridUserData[] ds = m_Database.GetAll(userID);
@@ -107,6 +148,13 @@ namespace OpenSim.Services.UserAccountService
107 } 148 }
108 } 149 }
109 150
151 return d;
152 }
153
154 public virtual GridUserInfo GetGridUserInfo(string userID)
155 {
156 GridUserData d = GetGridUserData(userID);
157
110 if (d == null) 158 if (d == null)
111 return null; 159 return null;
112 160
@@ -140,7 +188,8 @@ namespace OpenSim.Services.UserAccountService
140 public GridUserInfo LoggedIn(string userID) 188 public GridUserInfo LoggedIn(string userID)
141 { 189 {
142 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID); 190 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID);
143 GridUserData d = m_Database.Get(userID); 191
192 GridUserData d = GetGridUserData(userID);
144 193
145 if (d == null) 194 if (d == null)
146 { 195 {
@@ -159,7 +208,8 @@ namespace OpenSim.Services.UserAccountService
159 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 208 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
160 { 209 {
161 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID); 210 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID);
162 GridUserData d = m_Database.Get(userID); 211
212 GridUserData d = GetGridUserData(userID);
163 213
164 if (d == null) 214 if (d == null)
165 { 215 {
@@ -178,7 +228,8 @@ namespace OpenSim.Services.UserAccountService
178 228
179 public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt) 229 public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt)
180 { 230 {
181 GridUserData d = m_Database.Get(userID); 231 GridUserData d = GetGridUserData(userID);
232
182 if (d == null) 233 if (d == null)
183 { 234 {
184 d = new GridUserData(); 235 d = new GridUserData();
@@ -196,7 +247,8 @@ namespace OpenSim.Services.UserAccountService
196 { 247 {
197// m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID); 248// m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID);
198 249
199 GridUserData d = m_Database.Get(userID); 250 GridUserData d = GetGridUserData(userID);
251
200 if (d == null) 252 if (d == null)
201 { 253 {
202 d = new GridUserData(); 254 d = new GridUserData();
@@ -210,4 +262,4 @@ namespace OpenSim.Services.UserAccountService
210 return m_Database.Store(d); 262 return m_Database.Store(d);
211 } 263 }
212 } 264 }
213} 265} \ No newline at end of file