public static ScenePresence AddChildClient(
Scene scene, LLUDPServer udpServer, UUID agentId, UUID sessionId, uint circuitCode)
{
IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
UseCircuitCodePacket uccp = new UseCircuitCodePacket();
UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
= new UseCircuitCodePacket.CircuitCodeBlock();
uccpCcBlock.Code = circuitCode;
uccpCcBlock.ID = agentId;
uccpCcBlock.SessionID = sessionId;
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);
AgentCircuitData acd = new AgentCircuitData();
acd.AgentID = agentId;
acd.SessionID = sessionId;
scene.AuthenticateHandler.AddNewCircuit(circuitCode, acd);
udpServer.PacketReceived(upb);
return scene.GetScenePresence(agentId);
}