From d0019704e60da8392f505f1bb783ee668b0299b1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 23 Oct 2009 09:47:45 +0100 Subject: Adding the presence service skeleton --- .../Services/PresenceService/PresenceService.cs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 OpenSim/Services/PresenceService/PresenceService.cs (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs new file mode 100644 index 0000000..6e59642 --- /dev/null +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Services.PresenceService +{ + public class PresenceService : PresenceServiceBase, IPresenceService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + public PresenceService(IConfigSource config) + : base(config) + { + } + } +} -- cgit v1.1 From 69fba2647d47b289383d40fbe0593be5f303201d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Nov 2009 20:16:49 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Services/PresenceService/PresenceService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 6e59642..ba8eec8 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -41,9 +41,9 @@ namespace OpenSim.Services.PresenceService { public class PresenceService : PresenceServiceBase, IPresenceService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); public PresenceService(IConfigSource config) : base(config) -- cgit v1.1 From 0cd3bf074a9cc50d47e6e1873a9a5346453110ce Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Nov 2009 06:19:39 +0000 Subject: Change PresenceData to PresenceInfo to remove a naming conflict in the OpenSim.Data namespace --- OpenSim/Services/PresenceService/PresenceService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index ba8eec8..8931a26 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -49,5 +49,10 @@ namespace OpenSim.Services.PresenceService : base(config) { } + + public bool Report(PresenceInfo presence) + { + return false; + } } } -- cgit v1.1 From 06ecdf1967848e3f0c6b6f98aba61c7ad099f65d Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Nov 2009 08:21:28 +0000 Subject: Tweak presence handling and whip up a database connector and handler for testign the new generic table handling --- OpenSim/Services/PresenceService/PresenceService.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 8931a26..2157462 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -52,6 +52,15 @@ namespace OpenSim.Services.PresenceService public bool Report(PresenceInfo presence) { + PresenceData p = new PresenceData(); + p.Data = new Dictionary(); + + p.UUID = presence.PrincipalID; + p.currentRegion = presence.RegionID; + + foreach (KeyValuePair kvp in presence.Data) + p.Data[kvp.Key] = kvp.Value; + return false; } } -- cgit v1.1 From 982e3ff5d927df498c1d14111e2c61f0251c09d4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 01:27:51 +0000 Subject: Presence Step 1 --- OpenSim/Services/PresenceService/PresenceService.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 2157462..04bcee6 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -55,11 +55,8 @@ namespace OpenSim.Services.PresenceService PresenceData p = new PresenceData(); p.Data = new Dictionary(); - p.UUID = presence.PrincipalID; - p.currentRegion = presence.RegionID; - - foreach (KeyValuePair kvp in presence.Data) - p.Data[kvp.Key] = kvp.Value; + p.PrincipalID = presence.PrincipalID; + p.RegionID = presence.RegionID; return false; } -- cgit v1.1 From 490c09363641c6f90b8c4fc574d47daee6074a63 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 02:11:25 +0000 Subject: Just make it compile :) --- .../Services/PresenceService/PresenceService.cs | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 04bcee6..9f0e4da 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -50,15 +50,36 @@ namespace OpenSim.Services.PresenceService { } - public bool Report(PresenceInfo presence) + public bool LoginAgent(UUID principalID, UUID sessionID, + UUID secureSessionID) { - PresenceData p = new PresenceData(); - p.Data = new Dictionary(); + return false; + } - p.PrincipalID = presence.PrincipalID; - p.RegionID = presence.RegionID; + public bool LogoutAgent(UUID sessionID) + { + return false; + } + public bool LogoutRegionAgents(UUID regionID) + { return false; } + + + public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + { + return false; + } + + public PresenceInfo GetAgent(UUID sessionID) + { + return null; + } + + public PresenceInfo[] GetAgents(UUID[] PrincipalIDs) + { + return null; + } } } -- cgit v1.1 From 8b9332e321d14815dbac8fcdc145480cddaf412c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 03:00:54 +0000 Subject: Finish the presence service --- .../Services/PresenceService/PresenceService.cs | 78 ++++++++++++++++++++-- 1 file changed, 73 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 9f0e4da..56ec504 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -53,33 +53,101 @@ namespace OpenSim.Services.PresenceService public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID) { - return false; + // We have just logged in. If there is any info in the table + // it's OK to overwrite. So we won't bother reading it first + // + PresenceData data = new PresenceData(); + + data.PrincipalID = principalID; + data.RegionID = UUID.Zero; + data.SessionID = sessionID; + data.Data["SecureSessionID"] = secureSessionID.ToString(); + data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); + + m_Database.Store(data); + + return true; } public bool LogoutAgent(UUID sessionID) { + PresenceData data = m_Database.Get(sessionID); + if (data == null) + return false; + + data.Data["Online"] = "false"; + data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); + + m_Database.Store(data); + return false; } public bool LogoutRegionAgents(UUID regionID) { - return false; + m_Database.LogoutRegionAgents(regionID); + + return true; } public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { - return false; + return m_Database.ReportAgent(sessionID, regionID, + position.ToString(), lookAt.ToString()); } public PresenceInfo GetAgent(UUID sessionID) { - return null; + PresenceInfo ret = new PresenceInfo(); + + PresenceData data = m_Database.Get(sessionID); + if (data == null) + return null; + + ret.PrincipalID = data.PrincipalID; + ret.RegionID = data.RegionID; + ret.SessionID = data.SessionID; + ret.SecureSessionID = new UUID(data.Data["SecureSessionID"]); + ret.Online = bool.Parse(data.Data["Online"]); + ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); + ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); + ret.Position = Vector3.Parse(data.Data["Position"]); + ret.LookAt = Vector3.Parse(data.Data["LookAt"]); + + return ret; } public PresenceInfo[] GetAgents(UUID[] PrincipalIDs) { - return null; + List info = new List(); + + foreach (UUID principalID in PrincipalIDs) + { + PresenceData[] data = m_Database.Get("PrincipalID", + principalID.ToString()); + + foreach (PresenceData d in data) + { + PresenceInfo ret = new PresenceInfo(); + + ret.PrincipalID = d.PrincipalID; + ret.RegionID = d.RegionID; + ret.SessionID = d.SessionID; + ret.SecureSessionID = new UUID(d.Data["SecureSessionID"]); + ret.Online = bool.Parse(d.Data["Online"]); + ret.Login = Util.ToDateTime(Convert.ToInt32( + d.Data["Login"])); + ret.Logout = Util.ToDateTime(Convert.ToInt32( + d.Data["Logout"])); + ret.Position = Vector3.Parse(d.Data["Position"]); + ret.LookAt = Vector3.Parse(d.Data["LookAt"]); + + info.Add(ret); + } + } + + return info.ToArray(); } } } -- cgit v1.1 From 2f717fc796fcb2641369dc132d1fbc7a70d43d72 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Dec 2009 18:03:59 +0000 Subject: Remove the sesion from returned presence info --- OpenSim/Services/PresenceService/PresenceService.cs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 56ec504..6542c25 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -107,8 +107,6 @@ namespace OpenSim.Services.PresenceService ret.PrincipalID = data.PrincipalID; ret.RegionID = data.RegionID; - ret.SessionID = data.SessionID; - ret.SecureSessionID = new UUID(data.Data["SecureSessionID"]); ret.Online = bool.Parse(data.Data["Online"]); ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); @@ -133,8 +131,6 @@ namespace OpenSim.Services.PresenceService ret.PrincipalID = d.PrincipalID; ret.RegionID = d.RegionID; - ret.SessionID = d.SessionID; - ret.SecureSessionID = new UUID(d.Data["SecureSessionID"]); ret.Online = bool.Parse(d.Data["Online"]); ret.Login = Util.ToDateTime(Convert.ToInt32( d.Data["Login"])); -- cgit v1.1 From b8dfccb2272e12942f5364fa327ffd721292d8ad Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Dec 2009 16:07:16 -0800 Subject: Changed GetAgents to take string[] instead of UUID[] --- .../Services/PresenceService/PresenceService.cs | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 6542c25..0529d3d 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -116,30 +116,34 @@ namespace OpenSim.Services.PresenceService return ret; } - public PresenceInfo[] GetAgents(UUID[] PrincipalIDs) + public PresenceInfo[] GetAgents(string[] principalIDs) { List info = new List(); - foreach (UUID principalID in PrincipalIDs) + foreach (string principalIDStr in principalIDs) { - PresenceData[] data = m_Database.Get("PrincipalID", - principalID.ToString()); - - foreach (PresenceData d in data) + UUID principalID = UUID.Zero; + if (UUID.TryParse(principalIDStr, out principalID)) { - PresenceInfo ret = new PresenceInfo(); - - ret.PrincipalID = d.PrincipalID; - ret.RegionID = d.RegionID; - ret.Online = bool.Parse(d.Data["Online"]); - ret.Login = Util.ToDateTime(Convert.ToInt32( - d.Data["Login"])); - ret.Logout = Util.ToDateTime(Convert.ToInt32( - d.Data["Logout"])); - ret.Position = Vector3.Parse(d.Data["Position"]); - ret.LookAt = Vector3.Parse(d.Data["LookAt"]); - - info.Add(ret); + PresenceData[] data = m_Database.Get("PrincipalID", + principalID.ToString()); + + foreach (PresenceData d in data) + { + PresenceInfo ret = new PresenceInfo(); + + ret.PrincipalID = d.PrincipalID; + ret.RegionID = d.RegionID; + ret.Online = bool.Parse(d.Data["Online"]); + ret.Login = Util.ToDateTime(Convert.ToInt32( + d.Data["Login"])); + ret.Logout = Util.ToDateTime(Convert.ToInt32( + d.Data["Logout"])); + ret.Position = Vector3.Parse(d.Data["Position"]); + ret.LookAt = Vector3.Parse(d.Data["LookAt"]); + + info.Add(ret); + } } } -- cgit v1.1 From 92a40129b5dfde0d8ef798941f5efb31ca3a73fd Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 17:34:42 +0000 Subject: Database and presence changes. Untested --- .../Services/PresenceService/PresenceService.cs | 48 ++++++++++------------ 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 0529d3d..fe36bd0 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -50,7 +50,7 @@ namespace OpenSim.Services.PresenceService { } - public bool LoginAgent(UUID principalID, UUID sessionID, + public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { // We have just logged in. If there is any info in the table @@ -58,7 +58,7 @@ namespace OpenSim.Services.PresenceService // PresenceData data = new PresenceData(); - data.PrincipalID = principalID; + data.UserID = userID; data.RegionID = UUID.Zero; data.SessionID = sessionID; data.Data["SecureSessionID"] = secureSessionID.ToString(); @@ -105,7 +105,7 @@ namespace OpenSim.Services.PresenceService if (data == null) return null; - ret.PrincipalID = data.PrincipalID; + ret.UserID = data.UserID; ret.RegionID = data.RegionID; ret.Online = bool.Parse(data.Data["Online"]); ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); @@ -116,34 +116,30 @@ namespace OpenSim.Services.PresenceService return ret; } - public PresenceInfo[] GetAgents(string[] principalIDs) + public PresenceInfo[] GetAgents(string[] userIDs) { List info = new List(); - foreach (string principalIDStr in principalIDs) + foreach (string userIDStr in userIDs) { - UUID principalID = UUID.Zero; - if (UUID.TryParse(principalIDStr, out principalID)) + PresenceData[] data = m_Database.Get("UserID", + userIDStr); + + foreach (PresenceData d in data) { - PresenceData[] data = m_Database.Get("PrincipalID", - principalID.ToString()); - - foreach (PresenceData d in data) - { - PresenceInfo ret = new PresenceInfo(); - - ret.PrincipalID = d.PrincipalID; - ret.RegionID = d.RegionID; - ret.Online = bool.Parse(d.Data["Online"]); - ret.Login = Util.ToDateTime(Convert.ToInt32( - d.Data["Login"])); - ret.Logout = Util.ToDateTime(Convert.ToInt32( - d.Data["Logout"])); - ret.Position = Vector3.Parse(d.Data["Position"]); - ret.LookAt = Vector3.Parse(d.Data["LookAt"]); - - info.Add(ret); - } + PresenceInfo ret = new PresenceInfo(); + + ret.UserID = d.UserID; + ret.RegionID = d.RegionID; + ret.Online = bool.Parse(d.Data["Online"]); + ret.Login = Util.ToDateTime(Convert.ToInt32( + d.Data["Login"])); + ret.Logout = Util.ToDateTime(Convert.ToInt32( + d.Data["Logout"])); + ret.Position = Vector3.Parse(d.Data["Position"]); + ret.LookAt = Vector3.Parse(d.Data["LookAt"]); + + info.Add(ret); } } -- cgit v1.1 From 43691e827070f630a2acfbb70d88c1aa555f3f4d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Dec 2009 11:46:34 -0800 Subject: Added some more log messages. This is beginning to work. --- OpenSim/Services/PresenceService/PresenceService.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index fe36bd0..adbf430 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -41,13 +41,14 @@ namespace OpenSim.Services.PresenceService { public class PresenceService : PresenceServiceBase, IPresenceService { -// private static readonly ILog m_log = -// LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); public PresenceService(IConfigSource config) : base(config) { + m_log.Debug("[PRESENCE SERVICE]: Starting presence service"); } public bool LoginAgent(string userID, UUID sessionID, @@ -93,8 +94,9 @@ namespace OpenSim.Services.PresenceService public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { + m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); return m_Database.ReportAgent(sessionID, regionID, - position.ToString(), lookAt.ToString()); + position.ToString(), lookAt.ToString()); } public PresenceInfo GetAgent(UUID sessionID) -- cgit v1.1 From e0fc854f05b137c353196356e5b26d11b6ee6867 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 23:42:08 +0000 Subject: Adding new fields and home location methid to presence. Adding cleanup (deleting all but one presence record) on logout so that they don't pile up. --- .../Services/PresenceService/PresenceService.cs | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index adbf430..b3d8194 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -54,9 +54,10 @@ namespace OpenSim.Services.PresenceService public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { - // We have just logged in. If there is any info in the table - // it's OK to overwrite. So we won't bother reading it first - // + m_Database.Prune(userID); + + PresenceData[] d = m_Database.Get("UserID", userID); + PresenceData data = new PresenceData(); data.UserID = userID; @@ -64,6 +65,12 @@ namespace OpenSim.Services.PresenceService data.SessionID = sessionID; data.Data["SecureSessionID"] = secureSessionID.ToString(); data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); + if (d.Length > 0) + { + data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; + data.Data["HomePosition"] = d[0].Data["HomePosition"]; + data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; + } m_Database.Store(data); @@ -76,12 +83,20 @@ namespace OpenSim.Services.PresenceService if (data == null) return false; + PresenceData[] d = m_Database.Get("UserID", data.UserID); + + if (d.Length > 1) + { + m_Database.Delete("SessionID", sessionID.ToString()); + return true; + } + data.Data["Online"] = "false"; data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); m_Database.Store(data); - return false; + return true; } public bool LogoutRegionAgents(UUID regionID) @@ -114,6 +129,9 @@ namespace OpenSim.Services.PresenceService ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); ret.Position = Vector3.Parse(data.Data["Position"]); ret.LookAt = Vector3.Parse(data.Data["LookAt"]); + ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]); + ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]); + ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]); return ret; } @@ -140,6 +158,9 @@ namespace OpenSim.Services.PresenceService d.Data["Logout"])); ret.Position = Vector3.Parse(d.Data["Position"]); ret.LookAt = Vector3.Parse(d.Data["LookAt"]); + ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]); + ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]); + ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.Add(ret); } @@ -147,5 +168,10 @@ namespace OpenSim.Services.PresenceService return info.ToArray(); } + + public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + { + return m_Database.SetHomeLocation(userID, regionID, position, lookAt); + } } } -- cgit v1.1 From 1d2a332b96794e2011b0527cf590c3ceedcd8af4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 30 Dec 2009 14:17:18 -0800 Subject: Unit tests for presence. They helped fix a couple of wrongnesses. --- .../Services/PresenceService/PresenceService.cs | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index b3d8194..fc6a6e1 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -64,6 +64,7 @@ namespace OpenSim.Services.PresenceService data.RegionID = UUID.Zero; data.SessionID = sessionID; data.Data["SecureSessionID"] = secureSessionID.ToString(); + data.Data["Online"] = "true"; data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); if (d.Length > 0) { @@ -88,7 +89,6 @@ namespace OpenSim.Services.PresenceService if (d.Length > 1) { m_Database.Delete("SessionID", sessionID.ToString()); - return true; } data.Data["Online"] = "false"; @@ -110,6 +110,12 @@ namespace OpenSim.Services.PresenceService public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); + PresenceData pdata = m_Database.Get(sessionID); + if (pdata == null) + return false; + if (pdata.Data["Online"] == "false") + return false; + return m_Database.ReportAgent(sessionID, regionID, position.ToString(), lookAt.ToString()); } @@ -124,14 +130,22 @@ namespace OpenSim.Services.PresenceService ret.UserID = data.UserID; ret.RegionID = data.RegionID; - ret.Online = bool.Parse(data.Data["Online"]); - ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); - ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); - ret.Position = Vector3.Parse(data.Data["Position"]); - ret.LookAt = Vector3.Parse(data.Data["LookAt"]); - ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]); - ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]); - ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]); + if (data.Data.ContainsKey("Online")) + ret.Online = bool.Parse(data.Data["Online"]); + if (data.Data.ContainsKey("Login")) + ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); + if (data.Data.ContainsKey("Logout")) + ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); + if (data.Data.ContainsKey("Position")) + ret.Position = Vector3.Parse(data.Data["Position"]); + if (data.Data.ContainsKey("LookAt")) + ret.LookAt = Vector3.Parse(data.Data["LookAt"]); + if (data.Data.ContainsKey("HomeRegionID")) + ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]); + if (data.Data.ContainsKey("HomePosition")) + ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]); + if (data.Data.ContainsKey("HomeLookAt")) + ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]); return ret; } -- cgit v1.1 From 4240f2dec6f7348a99aea0d1b040fca6ea9d493b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 1 Jan 2010 16:54:24 -0800 Subject: New LL login service is working! -- tested in standalone only. Things still missing from response, namely Library and Friends. Appearance service is also missing. --- .../Services/PresenceService/PresenceService.cs | 40 +++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index fc6a6e1..7da0f23 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -63,15 +63,22 @@ namespace OpenSim.Services.PresenceService data.UserID = userID; data.RegionID = UUID.Zero; data.SessionID = sessionID; + data.Data = new Dictionary(); data.Data["SecureSessionID"] = secureSessionID.ToString(); data.Data["Online"] = "true"; data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); - if (d.Length > 0) + if (d != null && d.Length > 0) { data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; data.Data["HomePosition"] = d[0].Data["HomePosition"]; data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; } + else + { + data.Data["HomeRegionID"] = UUID.Zero.ToString(); + data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString(); + data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString(); + } m_Database.Store(data); @@ -86,9 +93,10 @@ namespace OpenSim.Services.PresenceService PresenceData[] d = m_Database.Get("UserID", data.UserID); + m_log.WarnFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length); if (d.Length > 1) { - m_Database.Delete("SessionID", sessionID.ToString()); + m_Database.Delete("UserID", data.UserID); } data.Data["Online"] = "false"; @@ -110,14 +118,28 @@ namespace OpenSim.Services.PresenceService public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); - PresenceData pdata = m_Database.Get(sessionID); - if (pdata == null) - return false; - if (pdata.Data["Online"] == "false") - return false; + try + { + PresenceData pdata = m_Database.Get(sessionID); + if (pdata == null) + return false; + if (pdata.Data == null) + return false; + + if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false")) + { + m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online"); + return false; + } - return m_Database.ReportAgent(sessionID, regionID, - position.ToString(), lookAt.ToString()); + return m_Database.ReportAgent(sessionID, regionID, + position.ToString(), lookAt.ToString()); + } + catch (Exception e) + { + m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent threw exception {0}", e.StackTrace); + return false; + } } public PresenceInfo GetAgent(UUID sessionID) -- cgit v1.1 From 08b507517b8dc33f66de1e0815af330bb3c54696 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 2 Jan 2010 18:18:13 -0800 Subject: Test client for remote presence connector, and for the service itself. Connector seems to work well. --- OpenSim/Services/PresenceService/PresenceService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 7da0f23..2884199 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -82,6 +82,8 @@ namespace OpenSim.Services.PresenceService m_Database.Store(data); + m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent {0} with session {1} and ssession {2}", + userID, sessionID, secureSessionID); return true; } @@ -93,7 +95,7 @@ namespace OpenSim.Services.PresenceService PresenceData[] d = m_Database.Get("UserID", data.UserID); - m_log.WarnFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length); + m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length); if (d.Length > 1) { m_Database.Delete("UserID", data.UserID); @@ -117,7 +119,7 @@ namespace OpenSim.Services.PresenceService public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { - m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); + //m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); try { PresenceData pdata = m_Database.Get(sessionID); -- cgit v1.1 From 4dd523b45d1e635c66eb4e556764fabe29dbfc58 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 15:34:56 -0800 Subject: * Changed IPresenceService Logout, so that it takes a position and a lookat * CommsManager.AvatarService rerouted --- OpenSim/Services/PresenceService/PresenceService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 2884199..34a3154 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -87,7 +87,7 @@ namespace OpenSim.Services.PresenceService return true; } - public bool LogoutAgent(UUID sessionID) + public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) { PresenceData data = m_Database.Get(sessionID); if (data == null) @@ -103,6 +103,8 @@ namespace OpenSim.Services.PresenceService data.Data["Online"] = "false"; data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); + data.Data["Position"] = position.ToString(); + data.Data["LookAt"] = lookat.ToString(); m_Database.Store(data); -- cgit v1.1 From 7356860b487febd12c2e0de2f009a6df9ea0aeec Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 09:17:30 -0800 Subject: Several more buglets removed. --- OpenSim/Services/PresenceService/PresenceService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 34a3154..350eac8 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -121,7 +121,7 @@ namespace OpenSim.Services.PresenceService public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { - //m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); + m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); try { PresenceData pdata = m_Database.Get(sessionID); -- cgit v1.1 From bbb43f9bdeda4994653c72fac62f9023d6dbdcdc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Feb 2010 10:35:23 -0800 Subject: Now showing friends online upon grid login. --- OpenSim/Services/PresenceService/PresenceService.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 350eac8..1a31965 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -206,6 +206,7 @@ namespace OpenSim.Services.PresenceService } } + m_log.DebugFormat("[PRESENCE SERVICE]: GetAgents for {0} userIDs found {1} presences", userIDs.Length, info.Count); return info.ToArray(); } -- cgit v1.1 From 9ea6509a1c37108b7925f071e8d2c3727d38f6f7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 8 Mar 2010 21:08:48 +0000 Subject: Comment a debug message that is a tad too spammy --- OpenSim/Services/PresenceService/PresenceService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 1a31965..304538a 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -206,7 +206,7 @@ namespace OpenSim.Services.PresenceService } } - m_log.DebugFormat("[PRESENCE SERVICE]: GetAgents for {0} userIDs found {1} presences", userIDs.Length, info.Count); + // m_log.DebugFormat("[PRESENCE SERVICE]: GetAgents for {0} userIDs found {1} presences", userIDs.Length, info.Count); return info.ToArray(); } -- cgit v1.1 From ed3288a8db33be13e9e278d47cc00b3666d9d262 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 12 Mar 2010 10:16:21 -0800 Subject: Bug fix: "last location" login. --- OpenSim/Services/PresenceService/PresenceService.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 304538a..ea8d673 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -72,6 +72,10 @@ namespace OpenSim.Services.PresenceService data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; data.Data["HomePosition"] = d[0].Data["HomePosition"]; data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; + data.Data["Position"] = d[0].Data["Position"]; + data.Data["LookAt"] = d[0].Data["LookAt"]; + + data.RegionID = d[0].RegionID; } else { -- cgit v1.1 From a58859a0d4206c194c9c56212218e2cafc2cc373 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 7 May 2010 21:29:56 -0700 Subject: GridUserService in place. Replaces the contrived concept of storing user's home and position info in the presence service. WARNING: I violated a taboo by deleting 2 migration files and simplifying the original table creation for Presence. This should not cause any problems to anyone, though. Things will work with the new simplified table, as well as with the previous contrived one. If there are any problems, solving them is as easy as dropping the presence table and deleting its row in the migrations table. The presence info only exists during a user's session anyway. BTW, the Meshing files want to be committed too -- EOFs. --- .../Services/PresenceService/PresenceService.cs | 79 ++-------------------- 1 file changed, 5 insertions(+), 74 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index ea8d673..7e7e98e 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -54,8 +54,6 @@ namespace OpenSim.Services.PresenceService public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { - m_Database.Prune(userID); - PresenceData[] d = m_Database.Get("UserID", userID); PresenceData data = new PresenceData(); @@ -65,24 +63,6 @@ namespace OpenSim.Services.PresenceService data.SessionID = sessionID; data.Data = new Dictionary(); data.Data["SecureSessionID"] = secureSessionID.ToString(); - data.Data["Online"] = "true"; - data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); - if (d != null && d.Length > 0) - { - data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; - data.Data["HomePosition"] = d[0].Data["HomePosition"]; - data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; - data.Data["Position"] = d[0].Data["Position"]; - data.Data["LookAt"] = d[0].Data["LookAt"]; - - data.RegionID = d[0].RegionID; - } - else - { - data.Data["HomeRegionID"] = UUID.Zero.ToString(); - data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString(); - data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString(); - } m_Database.Store(data); @@ -91,28 +71,10 @@ namespace OpenSim.Services.PresenceService return true; } - public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) + public bool LogoutAgent(UUID sessionID) { - PresenceData data = m_Database.Get(sessionID); - if (data == null) - return false; - - PresenceData[] d = m_Database.Get("UserID", data.UserID); - - m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length); - if (d.Length > 1) - { - m_Database.Delete("UserID", data.UserID); - } - - data.Data["Online"] = "false"; - data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); - data.Data["Position"] = position.ToString(); - data.Data["LookAt"] = lookat.ToString(); - - m_Database.Store(data); - - return true; + m_log.DebugFormat("[PRESENCE SERVICE]: Session {0} logout", sessionID); + return m_Database.Delete("SessionID", sessionID.ToString()); } public bool LogoutRegionAgents(UUID regionID) @@ -123,7 +85,7 @@ namespace OpenSim.Services.PresenceService } - public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); try @@ -134,14 +96,7 @@ namespace OpenSim.Services.PresenceService if (pdata.Data == null) return false; - if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false")) - { - m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online"); - return false; - } - - return m_Database.ReportAgent(sessionID, regionID, - position.ToString(), lookAt.ToString()); + return m_Database.ReportAgent(sessionID, regionID); } catch (Exception e) { @@ -160,22 +115,10 @@ namespace OpenSim.Services.PresenceService ret.UserID = data.UserID; ret.RegionID = data.RegionID; - if (data.Data.ContainsKey("Online")) - ret.Online = bool.Parse(data.Data["Online"]); - if (data.Data.ContainsKey("Login")) - ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); - if (data.Data.ContainsKey("Logout")) - ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); if (data.Data.ContainsKey("Position")) ret.Position = Vector3.Parse(data.Data["Position"]); if (data.Data.ContainsKey("LookAt")) ret.LookAt = Vector3.Parse(data.Data["LookAt"]); - if (data.Data.ContainsKey("HomeRegionID")) - ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]); - if (data.Data.ContainsKey("HomePosition")) - ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]); - if (data.Data.ContainsKey("HomeLookAt")) - ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]); return ret; } @@ -195,16 +138,8 @@ namespace OpenSim.Services.PresenceService ret.UserID = d.UserID; ret.RegionID = d.RegionID; - ret.Online = bool.Parse(d.Data["Online"]); - ret.Login = Util.ToDateTime(Convert.ToInt32( - d.Data["Login"])); - ret.Logout = Util.ToDateTime(Convert.ToInt32( - d.Data["Logout"])); ret.Position = Vector3.Parse(d.Data["Position"]); ret.LookAt = Vector3.Parse(d.Data["LookAt"]); - ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]); - ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]); - ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.Add(ret); } @@ -214,9 +149,5 @@ namespace OpenSim.Services.PresenceService return info.ToArray(); } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - return m_Database.SetHomeLocation(userID, regionID, position, lookAt); - } } } -- cgit v1.1 From d72769930aebb14ae4bfee9803adb13fbb44eb8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 8 May 2010 07:44:07 -0700 Subject: More cleaning on presence. Friends online/offline works again. --- OpenSim/Services/PresenceService/PresenceService.cs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 7e7e98e..19f636a 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -115,10 +115,6 @@ namespace OpenSim.Services.PresenceService ret.UserID = data.UserID; ret.RegionID = data.RegionID; - if (data.Data.ContainsKey("Position")) - ret.Position = Vector3.Parse(data.Data["Position"]); - if (data.Data.ContainsKey("LookAt")) - ret.LookAt = Vector3.Parse(data.Data["LookAt"]); return ret; } @@ -138,8 +134,6 @@ namespace OpenSim.Services.PresenceService ret.UserID = d.UserID; ret.RegionID = d.RegionID; - ret.Position = Vector3.Parse(d.Data["Position"]); - ret.LookAt = Vector3.Parse(d.Data["LookAt"]); info.Add(ret); } -- cgit v1.1 From 2e2f73bdd5034febfa67c230257289f75946d8ce Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 20:12:06 +0100 Subject: minor: remove mono compiler warning --- OpenSim/Services/PresenceService/PresenceService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 19f636a..601a69f 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -54,7 +54,8 @@ namespace OpenSim.Services.PresenceService public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { - PresenceData[] d = m_Database.Get("UserID", userID); + //PresenceData[] d = m_Database.Get("UserID", userID); + m_Database.Get("UserID", userID); PresenceData data = new PresenceData(); -- cgit v1.1 From 952029380a6a038e382dd3b2c312b3e16ff08625 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 4 Jun 2010 10:59:59 -0700 Subject: Fixed a couple of buglets in Friendship offers / acceptance / decline when avies are in different sims. --- OpenSim/Services/PresenceService/PresenceService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 601a69f..976153f 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -55,7 +55,7 @@ namespace OpenSim.Services.PresenceService UUID secureSessionID) { //PresenceData[] d = m_Database.Get("UserID", userID); - m_Database.Get("UserID", userID); + //m_Database.Get("UserID", userID); PresenceData data = new PresenceData(); -- cgit v1.1 From bcd784b3167d3be18ad803e89ae0e4afa74da068 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Oct 2010 21:49:26 +0100 Subject: for now, comment out some older or redundant log debug lines to make diagnostics easier --- OpenSim/Services/PresenceService/PresenceService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 976153f..09c31c3 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -88,7 +88,7 @@ namespace OpenSim.Services.PresenceService public bool ReportAgent(UUID sessionID, UUID regionID) { - m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); +// m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); try { PresenceData pdata = m_Database.Get(sessionID); -- cgit v1.1 From 1c8d19d714cf8595680a88930287e4da222535ee Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 5 Nov 2010 13:31:45 +0000 Subject: Delete existing presences for a user ID when they log in again. WARNING!!! This changes a default. The old default is to allow multiple presences, the new default disables this. As the feature currently has no users, this should not present any difficulty and will alleviate the presence issues somewhat. --- OpenSim/Services/PresenceService/PresenceService.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 09c31c3..c8ac38e 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -45,10 +45,20 @@ namespace OpenSim.Services.PresenceService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + protected bool m_allowDuplicatePresences = false; + public PresenceService(IConfigSource config) : base(config) { m_log.Debug("[PRESENCE SERVICE]: Starting presence service"); + + IConfig presenceConfig = config.Configs["PresenceService"]; + if (presenceConfig != null) + { + m_allowDuplicatePresences = + presenceConfig.GetBoolean("AllowDuplicatePresences", + m_allowDuplicatePresences); + } } public bool LoginAgent(string userID, UUID sessionID, @@ -57,6 +67,9 @@ namespace OpenSim.Services.PresenceService //PresenceData[] d = m_Database.Get("UserID", userID); //m_Database.Get("UserID", userID); + if (!m_allowDuplicatePresences) + m_Database.Delete("UserID", userID.ToString()); + PresenceData data = new PresenceData(); data.UserID = userID; -- cgit v1.1 From 59157d9d63c0e038ca0a619bfae1be3ed6f77677 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 30 Mar 2012 00:40:19 +0100 Subject: Add simple login test with online friends. Add IFriendsModule.GrantRights() for granting rights via a module call. Rename IFriendsModule.GetFriendPerms() -> GetRightsGrantedByFriend() to be more self-documenting and consistent with friends module terminology. Add some method doc. --- OpenSim/Services/PresenceService/PresenceService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index c8ac38e..ed2703e 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -151,11 +151,12 @@ namespace OpenSim.Services.PresenceService info.Add(ret); } + +// m_log.DebugFormat( +// "[PRESENCE SERVICE]: GetAgents for {0} found {1} presences", userIDStr, data.Length); } - // m_log.DebugFormat("[PRESENCE SERVICE]: GetAgents for {0} userIDs found {1} presences", userIDs.Length, info.Count); return info.ToArray(); } - } -} +} \ No newline at end of file -- cgit v1.1 From cf1686335f1b4a1b4166c514aef60d9b4e27f076 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 8 Apr 2014 19:53:35 +0300 Subject: Log when the presence service logs-out all the users in a region --- OpenSim/Services/PresenceService/PresenceService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index ed2703e..7cd720c 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -80,7 +80,7 @@ namespace OpenSim.Services.PresenceService m_Database.Store(data); - m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent {0} with session {1} and ssession {2}", + m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent {0} with session {1} and secure session {2}", userID, sessionID, secureSessionID); return true; } @@ -93,6 +93,7 @@ namespace OpenSim.Services.PresenceService public bool LogoutRegionAgents(UUID regionID) { + m_log.DebugFormat("[PRESENCE SERVICE]: Logout agents in region {0}", regionID); m_Database.LogoutRegionAgents(regionID); return true; -- cgit v1.1 From acc2c42a795b42df702ded3cc302daa8b3e4c04c Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 20 Apr 2014 12:47:30 +0300 Subject: Better logging in PresenceService, to help diagnose presence problems. --- .../Services/PresenceService/PresenceService.cs | 88 ++++++++++++++++------ 1 file changed, 63 insertions(+), 25 deletions(-) (limited to 'OpenSim/Services/PresenceService/PresenceService.cs') diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 7cd720c..0fe0200 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -41,9 +41,7 @@ namespace OpenSim.Services.PresenceService { public class PresenceService : PresenceServiceBase, IPresenceService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected bool m_allowDuplicatePresences = false; @@ -55,19 +53,15 @@ namespace OpenSim.Services.PresenceService IConfig presenceConfig = config.Configs["PresenceService"]; if (presenceConfig != null) { - m_allowDuplicatePresences = - presenceConfig.GetBoolean("AllowDuplicatePresences", - m_allowDuplicatePresences); + m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences); } } - public bool LoginAgent(string userID, UUID sessionID, - UUID secureSessionID) + public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { - //PresenceData[] d = m_Database.Get("UserID", userID); - //m_Database.Get("UserID", userID); + PresenceData prevUser = GetUser(userID); - if (!m_allowDuplicatePresences) + if (!m_allowDuplicatePresences && (prevUser != null)) m_Database.Delete("UserID", userID.ToString()); PresenceData data = new PresenceData(); @@ -80,20 +74,41 @@ namespace OpenSim.Services.PresenceService m_Database.Store(data); - m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent {0} with session {1} and secure session {2}", - userID, sessionID, secureSessionID); + string prevUserStr = ""; + if (prevUser != null) + prevUserStr = string.Format(". This user was already logged-in: session {0}, region {1}", prevUser.SessionID, prevUser.RegionID); + + m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent: session {0}, user {1}, region {2}, secure session {3}{4}", + data.SessionID, data.UserID, data.RegionID, secureSessionID, prevUserStr); + return true; } public bool LogoutAgent(UUID sessionID) { - m_log.DebugFormat("[PRESENCE SERVICE]: Session {0} logout", sessionID); + PresenceInfo presence = GetAgent(sessionID); + + m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent: session {0}, user {1}, region {2}", + sessionID, + (presence == null) ? null : presence.UserID, + (presence == null) ? null : presence.RegionID.ToString()); + return m_Database.Delete("SessionID", sessionID.ToString()); } public bool LogoutRegionAgents(UUID regionID) { - m_log.DebugFormat("[PRESENCE SERVICE]: Logout agents in region {0}", regionID); + PresenceData[] prevSessions = GetRegionAgents(regionID); + + if ((prevSessions == null) || (prevSessions.Length == 0)) + return true; + + m_log.DebugFormat("[PRESENCE SERVICE]: Logout users in region {0}: {1}", regionID, + string.Join(", ", Array.ConvertAll(prevSessions, session => session.UserID))); + + // There's a small chance that LogoutRegionAgents() will logout different users than the + // list that was logged above, but it's unlikely and not worth dealing with. + m_Database.LogoutRegionAgents(regionID); return true; @@ -102,20 +117,26 @@ namespace OpenSim.Services.PresenceService public bool ReportAgent(UUID sessionID, UUID regionID) { -// m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); try { - PresenceData pdata = m_Database.Get(sessionID); - if (pdata == null) - return false; - if (pdata.Data == null) - return false; + PresenceData presence = m_Database.Get(sessionID); + + bool success; + if (presence == null) + success = false; + else + success = m_Database.ReportAgent(sessionID, regionID); - return m_Database.ReportAgent(sessionID, regionID); + m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent{0}: session {1}, user {2}, region {3}. Previously: {4}", + success ? "" : " failed", + sessionID, (presence == null) ? null : presence.UserID, regionID, + (presence == null) ? "not logged-in" : "region " + presence.RegionID); + + return success; } catch (Exception e) { - m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent threw exception {0}", e.StackTrace); + m_log.Debug(string.Format("[PRESENCE SERVICE]: ReportAgent for session {0} threw exception ", sessionID), e); return false; } } @@ -140,8 +161,7 @@ namespace OpenSim.Services.PresenceService foreach (string userIDStr in userIDs) { - PresenceData[] data = m_Database.Get("UserID", - userIDStr); + PresenceData[] data = m_Database.Get("UserID", userIDStr); foreach (PresenceData d in data) { @@ -159,5 +179,23 @@ namespace OpenSim.Services.PresenceService return info.ToArray(); } + + /// + /// Return the user's Presence. This only really works well if !AllowDuplicatePresences, but that's the default. + /// + private PresenceData GetUser(string userID) + { + PresenceData[] data = m_Database.Get("UserID", userID); + if (data.Length > 0) + return data[0]; + else + return null; + } + + private PresenceData[] GetRegionAgents(UUID regionID) + { + return m_Database.Get("RegionID", regionID.ToString()); + } + } } \ No newline at end of file -- cgit v1.1