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.cs63
1 files changed, 59 insertions, 4 deletions
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index 43fa04b..bef1691 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -46,12 +46,66 @@ namespace OpenSim.Services.UserAccountService
46 46
47 public GridUserService(IConfigSource config) : base(config) 47 public GridUserService(IConfigSource config) : base(config)
48 { 48 {
49 m_log.Debug("[USER GRID SERVICE]: Starting user grid service"); 49 m_log.Debug("[GRID USER SERVICE]: Starting user grid service");
50
51 MainConsole.Instance.Commands.AddCommand(
52 "Users", false,
53 "show grid users online",
54 "show grid users online",
55 "Show number of grid users registered as online.",
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 + "For this reason, users online for more than 5 days are not currently counted",
58 HandleShowGridUsersOnline);
59 }
60
61 protected void HandleShowGridUsersOnline(string module, string[] cmdparams)
62 {
63// if (cmdparams.Length != 4)
64// {
65// MainConsole.Instance.Output("Usage: show grid users online");
66// return;
67// }
68
69// int onlineCount;
70 int onlineRecentlyCount = 0;
71
72 DateTime now = DateTime.UtcNow;
73
74 foreach (GridUserData gu in m_Database.GetAll(""))
75 {
76 if (bool.Parse(gu.Data["Online"]))
77 {
78// onlineCount++;
79
80 int unixLoginTime = int.Parse(gu.Data["Login"]);
81
82 if ((now - Util.ToDateTime(unixLoginTime)).Days < 5)
83 onlineRecentlyCount++;
84 }
85 }
86
87 MainConsole.Instance.OutputFormat("Users online: {0}", onlineRecentlyCount);
50 } 88 }
51 89
52 public virtual GridUserInfo GetGridUserInfo(string userID) 90 public virtual GridUserInfo GetGridUserInfo(string userID)
53 { 91 {
54 GridUserData d = m_Database.Get(userID); 92 GridUserData d = null;
93 if (userID.Length > 36) // it's a UUI
94 d = m_Database.Get(userID);
95 else // it's a UUID
96 {
97 GridUserData[] ds = m_Database.GetAll(userID);
98 if (ds == null)
99 return null;
100
101 if (ds.Length > 0)
102 {
103 d = ds[0];
104 foreach (GridUserData dd in ds)
105 if (dd.UserID.Length > d.UserID.Length) // find the longest
106 d = dd;
107 }
108 }
55 109
56 if (d == null) 110 if (d == null)
57 return null; 111 return null;
@@ -73,7 +127,7 @@ namespace OpenSim.Services.UserAccountService
73 return info; 127 return info;
74 } 128 }
75 129
76 public GridUserInfo[] GetGridUserInfo(string[] userIDs) 130 public virtual GridUserInfo[] GetGridUserInfo(string[] userIDs)
77 { 131 {
78 List<GridUserInfo> ret = new List<GridUserInfo>(); 132 List<GridUserInfo> ret = new List<GridUserInfo>();
79 133
@@ -140,7 +194,8 @@ namespace OpenSim.Services.UserAccountService
140 194
141 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 195 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
142 { 196 {
143 //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); 197// m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID);
198
144 GridUserData d = m_Database.Get(userID); 199 GridUserData d = m_Database.Get(userID);
145 if (d == null) 200 if (d == null)
146 { 201 {