AddNewClient() public method

Adding a New Client and Create a Presence for it.
public AddNewClient ( IClientAPI client ) : void
client IClientAPI
return void
Ejemplo n.º 1
0
        public UUID CreateNPC(
            string firstname,
            string lastname,
            Vector3 position,
            UUID owner,
            bool senseAsAgent,
            Scene scene,
            AvatarAppearance appearance)
        {
            NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene);
            npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);

            m_log.DebugFormat(
                "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
                firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);

            AgentCircuitData acd = new AgentCircuitData();
            acd.AgentID = npcAvatar.AgentId;
            acd.firstname = firstname;
            acd.lastname = lastname;
            acd.ServiceURLs = new Dictionary<string, object>();

            AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
            acd.Appearance = npcAppearance;

//            for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
//            {
//                m_log.DebugFormat(
//                    "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
//                    acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
//            }

            lock (m_avatars)
            {
                scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
                scene.AddNewClient(npcAvatar, PresenceType.Npc);

                ScenePresence sp;
                if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
                {
//                    m_log.DebugFormat(
//                        "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);

                    sp.CompleteMovement(npcAvatar, false);
                    m_avatars.Add(npcAvatar.AgentId, npcAvatar);
                    m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);

                    return npcAvatar.AgentId;
                }
                else
                {
                    m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
                    return UUID.Zero;
                }
            }
        }
Ejemplo n.º 2
0
        public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom)
        {
            NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene);
            npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);

            m_log.DebugFormat(
                "[NPC MODULE]: Creating NPC {0} {1} {2} at {3} in {4}",
                firstname, lastname, npcAvatar.AgentId, position, scene.RegionInfo.RegionName);

            AgentCircuitData acd = new AgentCircuitData();
            acd.AgentID = npcAvatar.AgentId;
            acd.firstname = firstname;
            acd.lastname = lastname;
            acd.ServiceURLs = new Dictionary<string, object>();

            AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene);
            AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
            acd.Appearance = npcAppearance;

            scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
            scene.AddNewClient(npcAvatar);

            ScenePresence sp;
            if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
            {
                m_log.DebugFormat(
                    "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);

                // Shouldn't call this - temporary.
                sp.CompleteMovement(npcAvatar);

//                        sp.SendAppearanceToAllOtherAgents();
//
//                        // Send animations back to the avatar as well
//                        sp.Animator.SendAnimPack();
            }
            else
            {
                m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
            }

            lock (m_avatars)
                m_avatars.Add(npcAvatar.AgentId, npcAvatar);

            m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);

            return npcAvatar.AgentId;
        }
Ejemplo n.º 3
0
        /// <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;
        }
Ejemplo n.º 4
0
        private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf)
        {
            string reason;

            // Stage 1: tell the scene to expect a new user connection
            if (!scene.NewUserConnection(agentData, (uint)tf, 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, PresenceType.User);

            return scene.GetScenePresence(agentData.AgentID);
        }
Ejemplo n.º 5
0
        /// <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;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Add a root agent.
        /// </summary>
        /// <remarks>
        /// 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
        /// </remarks>
        /// <param name="scene"></param>
        /// <param name="agentData"></param>
        /// <returns></returns>
        public static ScenePresence AddScenePresence(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, PresenceType.User);

            // Stage 3: Complete the entrance into the region.  This converts the child agent into a root agent.
            ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
            scp.CompleteMovement(client, true);
            //scp.MakeRootAgent(new Vector3(90, 90, 90), true);

            return scp;
        }