From 1b933c91160a27fe53f3dff2e706363190b1ede9 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 14 Aug 2009 19:12:42 -0400 Subject: * Put the StandaloneTeleportTest in a new thread and call Thread.Join() inside a try/Catch (ThreadAbortException) to try and get around scene code aborting the testing thread. Use a Messenger class to report the results back to the test thread. --- .../Scenes/Tests/StandaloneTeleportTests.cs | 115 +++++++++++++++++---- 1 file changed, 95 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs index ed2d317..23eab90 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs @@ -38,6 +38,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Setup; +using System.Threading; namespace OpenSim.Region.Framework.Scenes.Tests { @@ -55,56 +56,130 @@ namespace OpenSim.Region.Framework.Scenes.Tests public void TestSimpleNotNeighboursTeleport() { TestHelper.InMethod(); + ThreadRunResults results = new ThreadRunResults(); + results.Result = false; + results.Message = "Test did not run"; + TestRunning testClass = new TestRunning(results); + Thread testThread = new Thread(testClass.run); + + try + { + // Seems kind of redundant to start a thread and then join it, however.. We need to protect against + // A thread abort exception in the simulator code. + testThread.Start(); + testThread.Join(); + } + catch (ThreadAbortException) + { + + } + Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message); // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); + } + + } + + public class ThreadRunResults + { + public bool Result = false; + public string Message = string.Empty; + } + + public class TestRunning + { + public ThreadRunResults results; + public TestRunning(ThreadRunResults t) + { + results = t; + } + public void run(object o) + { + //results.Result = true; log4net.Config.XmlConfigurator.Configure(); - + UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); TestCommunicationsManager cm = new TestCommunicationsManager(); // shared module ISharedRegionModule interregionComms = new RESTInterregionComms(); - + Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm); SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); sceneA.RegisterRegionWithGrid(); - + Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm); SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); sceneB.RegisterRegionWithGrid(); - - UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); + + UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); TestClient client = SceneSetupHelpers.AddRootAgent(sceneA, agentId); - + ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface(); + + results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl); + if (!results.Result) + { + results.Message = "Incorrect caps object path set up in sceneA"; + return; + } + + /* Assert.That( - sceneACapsModule.GetCapsPath(agentId), - Is.EqualTo(client.CapsSeedUrl), + sceneACapsModule.GetCapsPath(agentId), + Is.EqualTo(client.CapsSeedUrl), "Incorrect caps object path set up in sceneA"); - + */ // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used. - client.TeleportTargetScene = sceneB; - client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40)); - Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); - Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); + + client.TeleportTargetScene = sceneB; + client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40)); + + results.Result = (sceneB.GetScenePresence(agentId) != null); + if (!results.Result) + { + results.Message = "Client does not have an agent in sceneB"; + return; + } + + //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); + //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); + + results.Result = (sceneA.GetScenePresence(agentId) == null); + if (!results.Result) + { + results.Message = "Client still had an agent in sceneA"; + return; + } + ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface(); - + + + results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl); + if (!results.Result) + { + results.Message = "Incorrect caps object path set up in sceneB"; + return; + } + // Temporary assertion - caps url construction should at least be doable through a method. + /* Assert.That( - "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/", - Is.EqualTo(client.CapsSeedUrl), - "Incorrect caps object path set up in sceneB"); - + "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/", + Is.EqualTo(client.CapsSeedUrl), + "Incorrect caps object path set up in sceneB"); + */ // This assertion will currently fail since we don't remove the caps paths when no longer needed //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path"); - + // TODO: Check that more of everything is as it should be - + // TODO: test what happens if we try to teleport to a region that doesn't exist } } -- cgit v1.1 From 2f61fb0243e8e6b4da6e2ca1847faaba3ccee3d9 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 14 Aug 2009 21:19:04 -0400 Subject: * minor : comments * also re-trigger panda --- .../Framework/Scenes/SceneCommunicationService.cs | 72 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 0140faa..c1e39a9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -48,6 +48,9 @@ namespace OpenSim.Region.Framework.Scenes public delegate void RemoveKnownRegionsFromAvatarList(UUID avatarID, List regionlst); + /// + /// Class that Region communications runs through + /// public class SceneCommunicationService //one instance per region { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -60,15 +63,46 @@ namespace OpenSim.Region.Framework.Scenes protected List m_agentsInTransit; + /// + /// An agent is crossing into this region + /// public event AgentCrossing OnAvatarCrossingIntoRegion; + + /// + /// A user will arrive shortly, set up appropriate credentials so it can connect + /// public event ExpectUserDelegate OnExpectUser; + + /// + /// A Prim will arrive shortly + /// public event ExpectPrimDelegate OnExpectPrim; public event CloseAgentConnection OnCloseAgentConnection; + + /// + /// A new prim has arrived + /// public event PrimCrossing OnPrimCrossingIntoRegion; + + /// + /// A New Region is up and available + /// public event RegionUp OnRegionUp; + + /// + /// We have a child agent for this avatar and we're getting a status update about it + /// public event ChildAgentUpdate OnChildAgentUpdate; //public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar; + + /// + /// Time to log one of our users off. Grid Service sends this mostly + /// public event LogOffUser OnLogOffUser; + + /// + /// A region wants land data from us! + /// public event GetLandData OnGetLandData; private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; @@ -123,11 +157,20 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Returns a region with the name closest to string provided + /// + /// Partial Region Name for matching + /// Region Information for the region public RegionInfo RequestClosestRegion(string name) { return m_commsProvider.GridService.RequestClosestRegion(name); } + /// + /// This region is shutting down, de-register all events! + /// De-Register region from Grid! + /// public void Close() { if (regionCommsHost != null) @@ -159,10 +202,9 @@ namespace OpenSim.Region.Framework.Scenes #region CommsManager Event handlers /// - /// + /// A New User will arrive shortly, Informs the scene that there's a new user on the way /// - /// - /// + /// Data we need to ensure that the agent can connect /// protected void NewUserConnection(AgentCircuitData agent) { @@ -174,6 +216,12 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// The Grid has requested us to log-off the user + /// + /// Unique ID of agent to log-off + /// The secret string that the region establishes with the grid when registering + /// The message to send to the user that tells them why they were logged off protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message) { handlerLogOffUser = OnLogOffUser; @@ -183,6 +231,11 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// A New Region is now available. Inform the scene that there is a new region available. + /// + /// Information about the new region that is available + /// True if the event was handled protected bool newRegionUp(RegionInfo region) { handlerRegionUp = OnRegionUp; @@ -194,6 +247,11 @@ namespace OpenSim.Region.Framework.Scenes return true; } + /// + /// Inform the scene that we've got an update about a child agent that we have + /// + /// + /// protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData) { handlerChildAgentUpdate = OnChildAgentUpdate; @@ -204,6 +262,7 @@ namespace OpenSim.Region.Framework.Scenes return true; } + protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) { handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion; @@ -213,6 +272,13 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// We have a new prim from a neighbor + /// + /// unique ID for the primative + /// XML2 encoded data of the primative + /// An Int that represents the version of the XMLMethod + /// True if the prim was accepted, false if it was not protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod) { handlerExpectPrim = OnExpectPrim; -- cgit v1.1 From f208628667aed5d1d98d17b5dda815ae5ed9bcc9 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 14 Aug 2009 21:37:25 -0400 Subject: * minor : Comments * Also re-trigger Panda. --- OpenSim/Region/Framework/Scenes/Scene.cs | 71 ++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 919075c..56e5ef0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2170,6 +2170,14 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in + /// + /// + /// + /// + /// + /// public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) { UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); @@ -2340,6 +2348,12 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Removes region from an avatar's known region list. This coincides with child agents. For each child agent, there will be a known region entry. + /// + /// + /// + /// public void HandleRemoveKnownRegionsFromAvatar(UUID avatarID, List regionslst) { ScenePresence av = GetScenePresence(avatarID); @@ -2355,12 +2369,19 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Closes all endpoints with the circuitcode provided. + /// + /// Circuit Code of the endpoint to close public override void CloseAllAgents(uint circuitcode) { // Called by ClientView to kill all circuit codes ClientManager.CloseAllAgents(circuitcode); } + /// + /// Inform all other ScenePresences on this Scene that someone else has changed position on the minimap. + /// public void NotifyMyCoarseLocationChange() { ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); @@ -2455,9 +2476,10 @@ namespace OpenSim.Region.Framework.Scenes /// The return bool should allow for connections to be refused, but as not all calling paths /// take proper notice of it let, we allowed banned users in still. /// - /// - /// - /// + /// CircuitData of the agent who is connecting + /// Outputs the reason for the false response on this string + /// True if the region accepts this agent. False if it does not. False will + /// also return a reason. public bool NewUserConnection(AgentCircuitData agent, out string reason) { // Don't disable this log message - it's too helpful @@ -2530,6 +2552,13 @@ namespace OpenSim.Region.Framework.Scenes return true; } + /// + /// Verifies that the user has a session on the Grid + /// + /// Circuit Data of the Agent we're verifying + /// Outputs the reason for the false response on this string + /// True if the user has a session on the grid. False if it does not. False will + /// also return a reason. public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) { reason = String.Empty; @@ -2542,6 +2571,13 @@ namespace OpenSim.Region.Framework.Scenes return result; } + /// + /// Verify if the user can connect to this region. Checks the banlist and ensures that the region is set for public access + /// + /// The circuit data for the agent + /// outputs the reason to this string + /// True if the region accepts this agent. False if it does not. False will + /// also return a reason. protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) { reason = String.Empty; @@ -2600,16 +2636,32 @@ namespace OpenSim.Region.Framework.Scenes return true; } + /// + /// Update an AgentCircuitData object with new information + /// + /// Information to update the AgentCircuitData with public void UpdateCircuitData(AgentCircuitData data) { m_authenticateHandler.UpdateAgentData(data); } + /// + /// Change the Circuit Code for the user's Circuit Data + /// + /// The old Circuit Code. Must match a previous circuit code + /// The new Circuit Code. Must not be an already existing circuit code + /// True if we successfully changed it. False if we did not public bool ChangeCircuitCode(uint oldcc, uint newcc) { return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); } + /// + /// The Grid has requested that we log-off a user. Log them off. + /// + /// Unique ID of the avatar to log-off + /// SecureSessionID of the user, or the RegionSecret text when logging on to the grid + /// message to display to the user. Reason for being logged off public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) { ScenePresence loggingOffUser = null; @@ -2675,6 +2727,13 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// We've got an update about an agent that sees into this region, + /// send it to ScenePresence for processing It's the full data. + /// + /// Agent that contains all of the relevant things about an agent. + /// Appearance, animations, position, etc. + /// true if we handled it. public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) { // m_log.DebugFormat( @@ -2692,6 +2751,12 @@ namespace OpenSim.Region.Framework.Scenes return false; } + /// + /// We've got an update about an agent that sees into this region, + /// send it to ScenePresence for processing It's only positional data + /// + /// AgentPosition that contains agent positional data so we can know what to send + /// true if we handled it. public virtual bool IncomingChildAgentDataUpdate(AgentPosition cAgentData) { //m_log.Debug(" XXX Scene IncomingChildAgentDataUpdate POSITION in " + RegionInfo.RegionName); -- cgit v1.1 From 95be3eccd28f39b33e70202d2db4f7d57a99c9c8 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sat, 15 Aug 2009 00:01:58 -0400 Subject: * minor: comments * also re-trigger panda --- OpenSim/Region/Framework/Scenes/Scene.cs | 101 ++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 56e5ef0..18d7bad 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1038,6 +1038,10 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Send out simstats data to all clients + /// + /// Stats on the Simulator's performance private void SendSimStatsPackets(SimStats stats) { List StatSendAgents = GetScenePresences(); @@ -1050,6 +1054,9 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Recount SceneObjectPart in parcel aabb + /// private void UpdateLand() { if (LandChannel != null) @@ -1061,11 +1068,17 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Update the terrain if it needs to be updated. + /// private void UpdateTerrain() { EventManager.TriggerTerrainTick(); } + /// + /// Back up queued up changes + /// private void UpdateStorageBackup() { if (!m_backingup) @@ -1078,6 +1091,9 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Sends out the OnFrame event to the modules + /// private void UpdateEvents() { m_eventManager.TriggerOnFrame(); @@ -1133,6 +1149,10 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Synchronous force backup. For deletes and links/unlinks + /// + /// Object to be backed up public void ForceSceneObjectBackup(SceneObjectGroup group) { if (group != null) @@ -1141,6 +1161,13 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Return object to avatar Message + /// + /// Avatar Unique Id + /// Name of object returned + /// Location of object returned + /// Reasion for object return public void AddReturn(UUID agentID, string objectName, Vector3 location, string reason) { lock (m_returns) @@ -1167,6 +1194,9 @@ namespace OpenSim.Region.Framework.Scenes #region Load Terrain + /// + /// Store the terrain in the persistant data store + /// public void SaveTerrain() { m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); @@ -1269,6 +1299,10 @@ namespace OpenSim.Region.Framework.Scenes #region Load Land + /// + /// Loads all Parcel data from the datastore for region identified by regionID + /// + /// Unique Identifier of the Region to load parcel data for public void loadAllLandObjectsFromStorage(UUID regionID) { m_log.Info("[SCENE]: Loading land objects from storage"); @@ -1322,6 +1356,20 @@ namespace OpenSim.Region.Framework.Scenes m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); } + + /// + /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) { Vector3 pos = Vector3.Zero; @@ -1412,6 +1460,19 @@ namespace OpenSim.Region.Framework.Scenes } } + + /// + /// Create a New SceneObjectGroup/Part by raycasting + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// public virtual void AddNewPrim(UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, PrimitiveBaseShape shape, byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, byte RayEndIsIntersection) @@ -1829,6 +1890,12 @@ namespace OpenSim.Region.Framework.Scenes return true; } + /// + /// Attachment rezzing + /// + /// Agent Unique ID + /// Object ID + /// False public virtual bool IncomingCreateObject(UUID userID, UUID itemID) { ScenePresence sp = GetScenePresence(userID); @@ -1841,6 +1908,13 @@ namespace OpenSim.Region.Framework.Scenes return false; } + /// + /// Adds a Scene Object group to the Scene. + /// Verifies that the creator of the object is not banned from the simulator. + /// Checks if the item is an Attachment + /// + /// + /// True if the SceneObjectGroup was added, False if it was not public bool AddSceneObject(SceneObjectGroup sceneObject) { // If the user is banned, we won't let any of their objects @@ -1933,6 +2007,10 @@ namespace OpenSim.Region.Framework.Scenes #region Add/Remove Avatar Methods + /// + /// Adding a New Client and Create a Presence for it. + /// + /// public override void AddNewClient(IClientAPI client) { SubscribeToClientEvents(client); @@ -1977,6 +2055,10 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnNewClient(client); } + /// + /// Register for events from the client + /// + /// The IClientAPI of the connected client protected virtual void SubscribeToClientEvents(IClientAPI client) { client.OnRegionHandShakeReply += SendLayerData; @@ -2070,8 +2152,8 @@ namespace OpenSim.Region.Framework.Scenes /// /// Teleport an avatar to their home region /// - /// - /// + /// The avatar's Unique ID + /// The IClientAPI for the client public virtual void TeleportClientHome(UUID agentId, IClientAPI client) { UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); @@ -2099,6 +2181,21 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Duplicates object specified by localID at position raycasted against RayTargetObject using + /// RayEnd and RayStart to determine what the angle of the ray is + /// + /// ID of object to duplicate + /// + /// Agent doing the duplication + /// Group of new object + /// The target of the Ray + /// The ending of the ray (farthest away point) + /// The Beginning of the ray (closest point) + /// Bool to bypass raycasting + /// The End specified is the place to add the object + /// Position the object at the center of the face that it's colliding with + /// Rotate the object the same as the localID object public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart, bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) -- cgit v1.1