From 67e66a2d34cc5df15c6110d6404bf1d126ec7315 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 30 Mar 2012 00:40:19 +0100 Subject: [PATCH] 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/Data/Null/NullFriendsData.cs | 31 +++++++- OpenSim/Data/Null/NullPresenceData.cs | 1 - .../Avatar/Friends/FriendsModule.cs | 50 +++++++------ .../Avatar/Friends/Tests/FriendModuleTests.cs | 73 ++++++++++++------- .../Presence/PresenceDetector.cs | 9 +-- .../World/Permissions/PermissionsModule.cs | 10 +-- .../Framework/Interfaces/IFriendsModule.cs | 24 +++++- .../Services/Interfaces/IFriendsService.cs | 8 ++ .../PresenceService/PresenceService.cs | 7 +- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 12 ++- OpenSim/Tests/Common/Mock/TestClient.cs | 36 +++++---- prebuild.xml | 1 + 12 files changed, 177 insertions(+), 85 deletions(-) diff --git a/OpenSim/Data/Null/NullFriendsData.cs b/OpenSim/Data/Null/NullFriendsData.cs index 0a4b2426a8..0be32a4ede 100644 --- a/OpenSim/Data/Null/NullFriendsData.cs +++ b/OpenSim/Data/Null/NullFriendsData.cs @@ -28,6 +28,8 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Reflection; +using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; @@ -36,12 +38,25 @@ namespace OpenSim.Data.Null { public class NullFriendsData : IFriendsData { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static List m_Data = new List(); public NullFriendsData(string connectionString, string realm) { } + /// + /// Clear all friends data + /// + /// + /// This is required by unit tests to clear the static data between test runs. + /// + public static void Clear() + { + m_Data.Clear(); + } + public FriendsData[] GetFriends(UUID principalID) { return GetFriends(principalID.ToString()); @@ -66,9 +81,16 @@ namespace OpenSim.Data.Null lst.ForEach(f => { FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID); - if (f2 != null) { f.Data["TheirFlags"] = f2.Data["Flags"]; } + if (f2 != null) + f.Data["TheirFlags"] = f2.Data["Flags"]; + +// m_log.DebugFormat( +// "[NULL FRIENDS DATA]: Got {0} {1} {2} for {3}", +// f.Friend, f.Data["Flags"], f2 != null ? f.Data["TheirFlags"] : "not found!", f.PrincipalID); }); +// m_log.DebugFormat("[NULL FRIENDS DATA]: Got {0} friends for {1}", lst.Count, userID); + return lst.ToArray(); } @@ -80,6 +102,9 @@ namespace OpenSim.Data.Null if (data == null) return false; +// m_log.DebugFormat( +// "[NULL FRIENDS DATA]: Storing {0} {1} {2}", data.PrincipalID, data.Friend, data.Data["Flags"]); + m_Data.Add(data); return true; @@ -98,6 +123,10 @@ namespace OpenSim.Data.Null FriendsData friend = lst.Find(delegate(FriendsData fdata) { return fdata.Friend == friendID; }); if (friendID != null) { +// m_log.DebugFormat( +// "[NULL FRIENDS DATA]: Deleting friend {0} {1} for {2}", +// friend.Friend, friend.Data["Flags"], friend.PrincipalID); + m_Data.Remove(friend); return true; } diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs index 91f1cc561e..c06c223a81 100644 --- a/OpenSim/Data/Null/NullPresenceData.cs +++ b/OpenSim/Data/Null/NullPresenceData.cs @@ -110,7 +110,6 @@ namespace OpenSim.Data.Null return false; } - public PresenceData[] Get(string field, string data) { if (Instance != this) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index ba37798b7d..ae551532e7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -51,6 +51,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { public class FriendsModule : ISharedRegionModule, IFriendsModule { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected bool m_Enabled = false; protected class UserFriendData @@ -72,7 +74,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } protected static readonly FriendInfo[] EMPTY_FRIENDS = new FriendInfo[0]; - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected List m_Scenes = new List(); @@ -156,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends InitModule(config); m_Enabled = true; - m_log.InfoFormat("[FRIENDS MODULE]: {0} enabled.", Name); + m_log.DebugFormat("[FRIENDS MODULE]: {0} enabled.", Name); } } } @@ -201,7 +202,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (!m_Enabled) return; - m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name); +// m_log.DebugFormat("[FRIENDS MODULE]: AddRegion on {0}", Name); m_Scenes.Add(scene); scene.RegisterModuleInterface(this); @@ -241,13 +242,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends #endregion - public virtual uint GetFriendPerms(UUID principalID, UUID friendID) + public virtual int GetRightsGrantedByFriend(UUID principalID, UUID friendID) { FriendInfo[] friends = GetFriends(principalID); FriendInfo finfo = GetFriend(friends, friendID); if (finfo != null) { - return (uint)finfo.TheirFlags; + return finfo.TheirFlags; } return 0; @@ -259,7 +260,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends client.OnApproveFriendRequest += OnApproveFriendRequest; client.OnDenyFriendRequest += OnDenyFriendRequest; client.OnTerminateFriendship += RemoveFriendship; - client.OnGrantUserRights += OnGrantUserRights; + client.OnGrantUserRights += GrantRights; // We need to cache information for child agents as well as root agents so that friend edit/move/delete // permissions will work across borders where both regions are on different simulators. @@ -356,10 +357,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Send the friends online List online = GetOnlineFriends(agentID); -// m_log.DebugFormat( -// "[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", -// client.Name, client.Scene.RegionInfo.RegionName, online.Count); - if (online.Count > 0) client.SendAgentOnline(online.ToArray()); @@ -421,23 +418,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends List GetOnlineFriends(UUID userID) { List friendList = new List(); - List online = new List(); FriendInfo[] friends = GetFriends(userID); foreach (FriendInfo fi in friends) { - if (((fi.TheirFlags & 1) != 0) && (fi.TheirFlags != -1)) + if (((fi.TheirFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1)) friendList.Add(fi.Friend); } + List online = new List(); + if (friendList.Count > 0) GetOnlineFriends(userID, friendList, online); +// m_log.DebugFormat( +// "[FRIENDS MODULE]: User {0} has {1} friends online", userID, online.Count); + return online; } protected virtual void GetOnlineFriends(UUID userID, List friendList, /*collector*/ List online) { +// m_log.DebugFormat( +// "[FRIENDS MODULE]: Looking for online presence of {0} users for {1}", friendList.Count, userID); + PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); foreach (PresenceInfo pi in presence) { @@ -703,13 +707,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } - private void OnGrantUserRights(IClientAPI remoteClient, UUID target, int rights) + public void GrantRights(IClientAPI remoteClient, UUID friendID, int rights) { UUID requester = remoteClient.AgentId; m_log.DebugFormat( "[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", - requester, rights, target); + requester, rights, friendID); FriendInfo[] friends = GetFriends(requester); if (friends.Length == 0) @@ -718,12 +722,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } // Let's find the friend in this user's friend list - FriendInfo friend = GetFriend(friends, target); + FriendInfo friend = GetFriend(friends, friendID); if (friend != null) // Found it { // Store it on the DB - if (!StoreRights(requester, target, rights)) + if (!StoreRights(requester, friendID, rights)) { remoteClient.SendAlertMessage("Unable to grant rights."); return; @@ -734,17 +738,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends friend.MyFlags = rights; // Always send this back to the original client - remoteClient.SendChangeUserRights(requester, target, rights); + remoteClient.SendChangeUserRights(requester, friendID, rights); // // Notify the friend // // Try local - if (LocalGrantRights(requester, target, myFlags, rights)) + if (LocalGrantRights(requester, friendID, myFlags, rights)) return; - PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); if (friendSessions != null && friendSessions.Length > 0) { PresenceInfo friendSession = friendSessions[0]; @@ -753,13 +757,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); // TODO: You might want to send the delta to save the lookup // on the other end!! - m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); + m_FriendsSimConnector.GrantRights(region, requester, friendID, myFlags, rights); } } } else { - m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", target, requester); + m_log.DebugFormat("[FRIENDS MODULE]: friend {0} not found for {1}", friendID, requester); } } @@ -976,8 +980,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends protected virtual void StoreFriendships(UUID agentID, UUID friendID) { - FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), 1); - FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), 1); + FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), (int)FriendRights.CanSeeOnline); + FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), (int)FriendRights.CanSeeOnline); } protected virtual bool DeleteFriendship(UUID agentID, UUID exfriendID) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs index 94a78cbd25..45b4264c91 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using Nini.Config; using NUnit.Framework; using OpenMetaverse; +using OpenSim.Data.Null; using OpenSim.Framework; using OpenSim.Region.CoreModules.Avatar.Friends; using OpenSim.Region.Framework.Scenes; @@ -63,6 +64,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests [SetUp] public void Init() { + // We must clear friends data between tests since Data.Null holds it in static properties. This is necessary + // so that different services and simulator can share the data in standalone mode. This is pretty horrible + // effectively the statics are global variables. + NullFriendsData.Clear(); + IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); // Not strictly necessary since FriendsModule assumes it is the default (!) @@ -110,8 +116,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests m_fm.AddFriendship(sp1.ControllingClient, user2Id); - m_scene.RemoveClient(sp1.UUID, true); - m_scene.RemoveClient(sp2.UUID, true); + // Not necessary for this test. CanSeeOnline is automatically granted. +// m_fm.GrantRights(sp1.ControllingClient, user2Id, (int)FriendRights.CanSeeOnline); + + // We must logout from the client end so that the presence service is correctly updated by the presence + // detector. This is listening to the OnConnectionClosed event on the client. + ((TestClient)sp1.ControllingClient).Logout(); + ((TestClient)sp2.ControllingClient).Logout(); +// m_scene.RemoveClient(sp1.UUID, true); +// m_scene.RemoveClient(sp2.UUID, true); ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id); @@ -120,33 +133,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0)); } -// [Test] -// public void TestLoginWithOnlineFriends() -// { -// TestHelpers.InMethod(); + [Test] + public void TestLoginWithOnlineFriends() + { + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + + UUID user1Id = TestHelpers.ParseTail(0x1); + UUID user2Id = TestHelpers.ParseTail(0x2); + +// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id); +// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); // -// UUID user1Id = TestHelpers.ParseTail(0x1); -// UUID user2Id = TestHelpers.ParseTail(0x2); -// -//// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id); -//// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); -//// -//// m_fm.AddFriendship(user1Id, user2Id); -// -// ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id); -// SceneHelpers.AddScenePresence(m_scene, user2Id); -// -// m_fm.AddFriendship(sp1.ControllingClient, user2Id); -//// m_fm.LocalGrantRights -// -// m_scene.RemoveClient(sp1.UUID, true); -// -// ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id); -// -// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0)); -// Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1)); -// } +// m_fm.AddFriendship(user1Id, user2Id); + + ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id); + ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, user2Id); + + m_fm.AddFriendship(sp1.ControllingClient, user2Id); + + // Not necessary for this test. CanSeeOnline is automatically granted. +// m_fm.GrantRights(sp1.ControllingClient, user2Id, (int)FriendRights.CanSeeOnline); + + // We must logout from the client end so that the presence service is correctly updated by the presence + // detector. This is listening to the OnConnectionClosed event on the client. +// ((TestClient)sp1.ControllingClient).Logout(); + ((TestClient)sp2.ControllingClient).Logout(); +// m_scene.RemoveClient(user2Id, true); + + ScenePresence sp2Redux = SceneHelpers.AddScenePresence(m_scene, user2Id); + + Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0)); + Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1)); + } [Test] public void TestAddFriendshipWhileOnline() diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index e2e383f060..ccfbf78a29 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -27,14 +27,12 @@ using System; using System.Collections.Generic; using System.Reflection; - +using log4net; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -using OpenMetaverse; -using log4net; - namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence { public class PresenceDetector @@ -97,7 +95,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence // m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); m_PresenceService.LogoutAgent(client.SessionId); } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index ac03747620..64759a7e12 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -487,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } - protected bool IsFriendWithPerms(UUID user,UUID objectOwner) + protected bool IsFriendWithPerms(UUID user, UUID objectOwner) { if (user == UUID.Zero) return false; @@ -495,11 +495,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (m_friendsModule == null) return false; - uint friendPerms = m_friendsModule.GetFriendPerms(user, objectOwner); - if ((friendPerms & (uint)FriendRights.CanModifyObjects) != 0) - return true; - - return false; + int friendPerms = m_friendsModule.GetRightsGrantedByFriend(user, objectOwner); + return (friendPerms & (int)FriendRights.CanModifyObjects) != 0; } protected bool IsEstateManager(UUID user) @@ -508,6 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions return m_scene.RegionInfo.EstateSettings.IsEstateManager(user); } + #endregion public bool PropagatePermissions() diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 061799e394..10bef1e2dc 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs @@ -55,7 +55,27 @@ namespace OpenSim.Region.Framework.Interfaces /// void RemoveFriendship(IClientAPI client, UUID exFriendID); - uint GetFriendPerms(UUID PrincipalID, UUID FriendID); + /// + /// Get permissions granted by a friend. + /// + /// The user. + /// The friend that granted. + /// The permissions. These come from the FriendRights enum. + int GetRightsGrantedByFriend(UUID PrincipalID, UUID FriendID); + + /// + /// Grant permissions for a friend. + /// + /// + /// This includes giving them the ability to see when the user is online and permission to edit the user's + /// objects. + /// Granting lower permissions than the friend currently has will rescind the extra permissions. + /// + /// The user granting the permissions. + /// The friend. + /// These come from the FriendRights enum. + void GrantRights(IClientAPI remoteClient, UUID friendID, int perms); + bool SendFriendsOnlineIfNeeded(IClientAPI client); } -} +} \ No newline at end of file diff --git a/OpenSim/Services/Interfaces/IFriendsService.cs b/OpenSim/Services/Interfaces/IFriendsService.cs index fe94242d90..d0d3b1002d 100644 --- a/OpenSim/Services/Interfaces/IFriendsService.cs +++ b/OpenSim/Services/Interfaces/IFriendsService.cs @@ -36,7 +36,15 @@ namespace OpenSim.Services.Interfaces { public UUID PrincipalID; public string Friend; + + /// + /// The permissions that this user has granted to the friend. + /// public int MyFlags; + + /// + /// The permissions that the friend has granted to this user. + /// public int TheirFlags; public FriendInfo() diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index c8ac38e63a..ed2703eda5 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 diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index aa904aad9c..5ffd863493 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -369,8 +369,11 @@ namespace OpenSim.Tests.Common agentData.AgentID = agentId; agentData.firstname = firstName; agentData.lastname = "testlastname"; - agentData.SessionID = UUID.Zero; - agentData.SecureSessionID = UUID.Zero; + + // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData. + agentData.SessionID = UUID.Random(); + agentData.SecureSessionID = UUID.Random(); + agentData.circuitcode = 123; agentData.BaseFolder = UUID.Zero; agentData.InventoryFolder = UUID.Zero; @@ -416,7 +419,10 @@ namespace OpenSim.Tests.Common // We emulate the proper login sequence here by doing things in four stages // Stage 0: login - scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); + // We need to punch through to the underlying service because scene will not, correctly, let us call it + // through it's reference to the LPSC + LocalPresenceServicesConnector lpsc = (LocalPresenceServicesConnector)scene.PresenceService; + lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); // Stages 1 & 2 ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index ace33434ee..ca00fffe0c 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -347,15 +347,9 @@ namespace OpenSim.Tests.Common.Mock get { return m_agentId; } } - public UUID SessionId - { - get { return UUID.Zero; } - } + public UUID SessionId { get; set; } - public UUID SecureSessionId - { - get { return UUID.Zero; } - } + public UUID SecureSessionId { get; set; } public virtual string FirstName { @@ -379,11 +373,9 @@ namespace OpenSim.Tests.Common.Mock get { return true; } set { } } - public bool IsLoggingOut - { - get { return false; } - set { } - } + + public bool IsLoggingOut { get; set; } + public UUID ActiveGroupId { get { return UUID.Zero; } @@ -449,6 +441,8 @@ namespace OpenSim.Tests.Common.Mock m_lastName = agentData.lastname; m_circuitCode = agentData.circuitcode; m_scene = scene; + SessionId = agentData.SessionID; + SecureSessionId = agentData.SecureSessionID; CapsSeedUrl = agentData.CapsPath; ReceivedOfflineNotifications = new List(); @@ -905,8 +899,24 @@ namespace OpenSim.Tests.Common.Mock { } + /// + /// This is a TestClient only method to do shutdown tasks that are normally carried out by LLUDPServer.RemoveClient() + /// + public void Logout() + { + // We must set this here so that the presence is removed from the PresenceService by the PresenceDetector + IsLoggingOut = true; + + Close(); + } + public void Close() { + // Fire the callback for this connection closing + // This is necesary to get the presence detector to notice that a client has logged out. + if (OnConnectionClosed != null) + OnConnectionClosed(this); + m_scene.RemoveClient(AgentId, true); } diff --git a/prebuild.xml b/prebuild.xml index c2bb8b5372..70a3fa21d4 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2912,6 +2912,7 @@ +