/// <summary> /// Add a root agent. /// </summary> /// /// This function /// /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the /// userserver if grid) would give initial login data back to the client and separately tell the scene that the /// agent was coming. /// /// 2) Connects the agent with the scene /// /// This function performs actions equivalent with notifying the scene that an agent is /// coming and then actually connecting the agent to the scene. The one step missed out is the very first /// /// <param name="scene"></param> /// <param name="agentData"></param> /// <returns></returns> public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData) { string reason; // We emulate the proper login sequence here by doing things in four stages // Stage 0: log the presence scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); // Stage 1: simulate login by telling the scene to expect a new user connection if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) { Console.WriteLine("NewUserConnection failed: " + reason); } // Stage 2: add the new client as a child agent to the scene TestClient client = new TestClient(agentData, scene); scene.AddNewClient(client); // Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance, // inventory, etc.) //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE ScenePresence scp = scene.GetScenePresence(agentData.AgentID); scp.MakeRootAgent(new Vector3(90, 90, 90), true); return(client); }
public void T012_TestAddNeighbourRegion() { TestHelper.InMethod(); string reason; if (acd1 == null) { fixNullPresence(); } scene.NewUserConnection(acd1, 0, out reason); if (testclient == null) { testclient = new TestClient(acd1, scene); } scene.AddNewClient(testclient); ScenePresence presence = scene.GetScenePresence(agent1); presence.MakeRootAgent(new Vector3(90, 90, 90), false); string cap = presence.ControllingClient.RequestClientInfo().CapsPath; presence.AddNeighbourRegion(region2, cap); presence.AddNeighbourRegion(region3, cap); List <ulong> neighbours = presence.GetKnownRegionList(); Assert.That(neighbours.Count, Is.EqualTo(2)); }
// I'm commenting this test, because this is not supposed to happen here //[Test] public void T020_TestMakeRootAgent() { TestHelper.InMethod(); ScenePresence presence = scene.GetScenePresence(agent1); Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); presence.MakeChildAgent(); Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); // Accepts 0 but rejects Constants.RegionSize Vector3 pos = new Vector3(0, unchecked (Constants.RegionSize - 1), 0); presence.MakeRootAgent(pos, true); Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); }
/// <summary> /// Add a root agent. /// </summary> /// /// This function /// /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the /// userserver if grid) would give initial login data back to the client and separately tell the scene that the /// agent was coming. /// /// 2) Connects the agent with the scene /// /// This function performs actions equivalent with notifying the scene that an agent is /// coming and then actually connecting the agent to the scene. The one step missed out is the very first /// /// <param name="scene"></param> /// <param name="agentData"></param> /// <returns></returns> public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData) { string reason; // We emulate the proper login sequence here by doing things in three stages // Stage 1: simulate login by telling the scene to expect a new user connection scene.NewUserConnection(agentData, out reason); // Stage 2: add the new client as a child agent to the scene TestClient client = new TestClient(agentData, scene); scene.AddNewClient(client); // Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance, // inventory, etc.) //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE ScenePresence scp = scene.GetScenePresence(agentData.AgentID); scp.MakeRootAgent(new Vector3(90, 90, 90), true); return(client); }
// I'm commenting this test because it does not represent // crossings. The Thread.Sleep's in here are not meaningful mocks, // and they sometimes fail in panda. // We need to talk in order to develop a test // that really tests region crossings. There are 3 async components, // but things are synchronous among them. So there should be // 3 threads in here. //[Test] public void T021_TestCrossToNewRegion() { TestHelper.InMethod(); scene.RegisterRegionWithGrid(); scene2.RegisterRegionWithGrid(); // Adding child agent to region 1001 string reason; scene2.NewUserConnection(acd1, 0, out reason); scene2.AddNewClient(testclient); ScenePresence presence = scene.GetScenePresence(agent1); presence.MakeRootAgent(new Vector3(0, unchecked (Constants.RegionSize - 1), 0), true); ScenePresence presence2 = scene2.GetScenePresence(agent1); // Adding neighbour region caps info to presence2 string cap = presence.ControllingClient.RequestClientInfo().CapsPath; presence2.AddNeighbourRegion(region1, cap); Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region."); Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region."); // Cross to x+1 presence.AbsolutePosition = new Vector3(Constants.RegionSize + 1, 3, 100); presence.Update(); EventWaitHandle wh = new EventWaitHandle(false, EventResetMode.AutoReset, "Crossing"); // Mimicking communication between client and server, by waiting OK from client // sent by TestClient.CrossRegion call. Originally, this is network comm. if (!wh.WaitOne(5000, false)) { presence.Update(); if (!wh.WaitOne(8000, false)) { throw new ArgumentException("1 - Timeout waiting for signal/variable."); } } // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which // would normally be fired after receiving the reply packet from comm. done on the last line. testclient.CompleteMovement(); // Crossings are asynchronous int timer = 10; // Make sure cross hasn't already finished if (!presence.IsInTransit && !presence.IsChildAgent) { // If not and not in transit yet, give it some more time Thread.Sleep(5000); } // Enough time, should at least be in transit by now. while (presence.IsInTransit && timer > 0) { Thread.Sleep(1000); timer -= 1; } Assert.That(timer, Is.GreaterThan(0), "Timed out waiting to cross 2->1."); Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected."); Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent."); // Cross Back presence2.AbsolutePosition = new Vector3(-10, 3, 100); presence2.Update(); if (!wh.WaitOne(5000, false)) { presence2.Update(); if (!wh.WaitOne(8000, false)) { throw new ArgumentException("2 - Timeout waiting for signal/variable."); } } testclient.CompleteMovement(); if (!presence2.IsInTransit && !presence2.IsChildAgent) { // If not and not in transit yet, give it some more time Thread.Sleep(5000); } // Enough time, should at least be in transit by now. while (presence2.IsInTransit && timer > 0) { Thread.Sleep(1000); timer -= 1; } Assert.That(timer, Is.GreaterThan(0), "Timed out waiting to cross 1->2."); Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); }