/// <summary> /// Add a client for testing /// </summary> /// <param name="scene"></param> /// <param name="testLLUDPServer"></param> /// <param name="testPacketServer"></param> /// <param name="acm">Agent circuit manager used in setting up the stack</param> protected void SetupStack( IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer, out AgentCircuitManager acm) { IConfigSource configSource = new IniConfigSource(); ClientStackUserSettings userSettings = new ClientStackUserSettings(); testLLUDPServer = new TestLLUDPServer(); acm = new AgentCircuitManager(); uint port = 666; testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm); testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); testLLUDPServer.LocalScene = scene; }
private void AddUdpServer(IniConfigSource configSource) { uint port = 0; AgentCircuitManager acm = m_scene.AuthenticateHandler; m_udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm); m_udpServer.AddScene(m_scene); }
public void TestAddClient() { TestHelpers.InMethod(); // XmlConfigurator.Configure(); TestScene scene = new SceneHelpers().SetupScene(); uint myCircuitCode = 123456; UUID myAgentUuid = TestHelpers.ParseTail(0x1); UUID mySessionUuid = TestHelpers.ParseTail(0x2); IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); uint port = 0; AgentCircuitManager acm = scene.AuthenticateHandler; TestLLUDPServer llUdpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm); llUdpServer.AddScene(scene); UseCircuitCodePacket uccp = new UseCircuitCodePacket(); UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock = new UseCircuitCodePacket.CircuitCodeBlock(); uccpCcBlock.Code = myCircuitCode; uccpCcBlock.ID = myAgentUuid; uccpCcBlock.SessionID = mySessionUuid; uccp.CircuitCode = uccpCcBlock; byte[] uccpBytes = uccp.ToBytes(); UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length); upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); llUdpServer.PacketReceived(upb); // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet Assert.That(scene.GetScenePresence(myAgentUuid), Is.Null); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = myAgentUuid; acd.SessionID = mySessionUuid; acm.AddNewCircuit(myCircuitCode, acd); llUdpServer.PacketReceived(upb); // Should succeed now ScenePresence sp = scene.GetScenePresence(myAgentUuid); Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(1)); Packet packet = llUdpServer.PacketsSent[0]; Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); PacketAckPacket ackPacket = packet as PacketAckPacket; Assert.That(ackPacket.Packets.Length, Is.EqualTo(1)); Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0)); }
/// <summary> /// Set up a client for tests which aren't concerned with this process itself and where only one client is being /// tested /// </summary> /// <param name="circuitCode"></param> /// <param name="epSender"></param> /// <param name="testLLUDPServer"></param> /// <param name="acm"></param> protected void AddClient( uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) { UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm); }
/// <summary> /// Set up a client for tests which aren't concerned with this process itself /// </summary> /// <param name="circuitCode"></param> /// <param name="epSender"></param> /// <param name="agentId"></param> /// <param name="sessionId"></param> /// <param name="testLLUDPServer"></param> /// <param name="acm"></param> protected void AddClient( uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) { AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = agentId; acd.SessionID = sessionId; UseCircuitCodePacket uccp = new UseCircuitCodePacket(); UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock = new UseCircuitCodePacket.CircuitCodeBlock(); uccpCcBlock.Code = circuitCode; uccpCcBlock.ID = agentId; uccpCcBlock.SessionID = sessionId; uccp.CircuitCode = uccpCcBlock; acm.AddNewCircuit(circuitCode, acd); testLLUDPServer.LoadReceive(uccp, epSender); testLLUDPServer.ReceiveData(null); }