Beispiel #1
0
        /// <summary>
        /// Terminates this user connection. Terminates UDP and tears down caps handlers and waits for the
        /// teardown to complete
        /// </summary>
        public void Terminate(bool waitForClose)
        {
            if (!_terminating)
            {
                _terminating = true;

                if (_udpCircuit != null)
                {
                    _udpCircuit.Close();
                }
                if (_capsControl != null)
                {
                    _capsControl.Teardown();
                }

                if (_udpCircuit != null && waitForClose)
                {
                    _udpCircuit.WaitForClose();
                }

                var terminatedHandler = OnConnectionTerminated;
                if (terminatedHandler != null)
                {
                    terminatedHandler(this);
                }
            }
            else
            {
                if (_udpCircuit != null && waitForClose)
                {
                    _udpCircuit.WaitForClose();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Completely close down the given client.
        /// </summary>
        /// <param name="client"></param>
        public virtual void CloseClient(IClientAPI client)
        {
            //m_log.Info("PacketServer:CloseClient()");

            CloseCircuit(client.CircuitCode);
            m_scene.ClientManager.Remove(client.CircuitCode);
            client.Close(false);
        }
Beispiel #3
0
        /// <summary>
        /// Adding a New Client and Create a Presence for it.
        /// </summary>
        /// <param name="client"></param>
        public override void AddNewClient(IClientAPI client)
        {
            AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
            bool vialogin = false;

            if (aCircuit == null) // no good, didn't pass NewUserConnection successfully
                return;

            m_clientManager.Add(client);
            SubscribeToClientEvents(client);

            // Do the verification here
            System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP();
            if (!VerifyClient(aCircuit, ep, out vialogin))
            {
                // uh-oh, this is fishy
                m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
                    client.AgentId, client.SessionId, ep.ToString());
                try
                {
                    client.Close();
                }
                catch (Exception e)
                {
                    m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
                }
                return;
            }

            //m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);

            ScenePresence sp = CreateAndAddScenePresence(client);
            if (aCircuit != null)
                sp.Appearance = aCircuit.Appearance;

            // HERE!!! Do the initial attachments right here
            // first agent upon login is a root agent by design.
            // All other AddNewClient calls find aCircuit.child to be true
            if (aCircuit.child == false)
            {
                sp.IsChildAgent = false;
                Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
            }

            if (GetScenePresence(client.AgentId) != null)
            {
                m_LastLogin = Util.EnvironmentTickCount();
                EventManager.TriggerOnNewClient(client);
                if (vialogin)
                    EventManager.TriggerOnClientLogin(client);
            }

            if (!sp.IsChildAgent && Stats is OpenSim.Framework.Statistics.SimExtraStatsCollector)
            {
                OpenSim.Framework.Statistics.SimExtraStatsCollector stats = Stats as OpenSim.Framework.Statistics.SimExtraStatsCollector;
                stats.AddSuccessfulLogin();
            }
        }
Beispiel #4
0
        protected void LogoutHandler(IClientAPI client)
        {
            client.SendLogoutPacket();

            if (!client.IsLoggingOut)
            {
                client.IsLoggingOut = true;
                client.Close();
            }
        }
Beispiel #5
0
        /// <summary>
        /// Deactivates the client if we don't receive any packets within a certain amount of time (default 60 seconds).
        /// </summary>
        /// <remarks>
        /// If a connection is active then we will always receive packets even if nothing else is happening, due to
        /// regular client pings.
        /// </remarks>
        /// <param name='client'></param>
        private void DeactivateClientDueToTimeout(IClientAPI client)
        {
            // We must set IsActive synchronously so that we can stop the packet loop reinvoking this method, even
            // though it's set later on by LLClientView.Close()
            client.IsActive = false;

            m_log.WarnFormat(
                "[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}",
                client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName);

            StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();

            if (!client.SceneAgent.IsChildAgent)
                 client.Kick("Simulator logged you out due to connection timeout");

            client.Close();
        }
Beispiel #6
0
        /// <summary>
        /// Adding a New Client and Create a Presence for it.
        /// </summary>
        /// <param name="client"></param>
        public override void AddNewClient(IClientAPI client)
        {
            bool vialogin = false;

            m_clientManager.Add(client);

            CheckHeartbeat();
            SubscribeToClientEvents(client);
            ScenePresence presence;

            if (m_restorePresences.ContainsKey(client.AgentId))
            {
                m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName);

                presence = m_restorePresences[client.AgentId];
                m_restorePresences.Remove(client.AgentId);

                // This is one of two paths to create avatars that are
                // used.  This tends to get called more in standalone
                // than grid, not really sure why, but as such needs
                // an explicity appearance lookup here.
                AvatarAppearance appearance = null;
                GetAvatarAppearance(client, out appearance);
                presence.Appearance = appearance;

                presence.initializeScenePresence(client, RegionInfo, this);

                m_sceneGraph.AddScenePresence(presence);

                lock (m_restorePresences)
                {
                    Monitor.PulseAll(m_restorePresences);
                }
            }
            else
            {
                AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);

                // Do the verification here
                System.Net.EndPoint ep = client.GetClientEP();
                if (aCircuit != null)
                {
                    if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
                    {
                        m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
                        vialogin = true;
                        IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
                        if (userVerification != null && ep != null)
                        {
                            if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
                            {
                                // uh-oh, this is fishy
                                m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
                                    client.AgentId, client.SessionId, ep.ToString());
                                try
                                {
                                    client.Close();
                                }
                                catch (Exception e)
                                {
                                    m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
                                }
                                return;
                            }
                            else
                                m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
                        }
                    }
                }

                m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);

                ScenePresence sp = CreateAndAddScenePresence(client);
                if (aCircuit != null)
                    sp.Appearance = aCircuit.Appearance;

                // HERE!!! Do the initial attachments right here
                // first agent upon login is a root agent by design.
                // All other AddNewClient calls find aCircuit.child to be true
                if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
                {
                    sp.IsChildAgent = false;
                    Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
                }
            }

            m_LastLogin = Util.EnvironmentTickCount();
            EventManager.TriggerOnNewClient(client);
            if (vialogin)
                EventManager.TriggerOnClientLogin(client);
        }
Beispiel #7
0
 private void RemoveClient(IClientAPI client)
 {
     try
     {
         client.Close();
     }
     catch (Exception e)
     {
         m_log.Error("[LLUDPSERVER] RemoveClient exception: " + e.ToString());
     }
 }
        /// <summary>
        /// Completely close down the given client.
        /// </summary>
        /// <param name="client"></param>
        public virtual void CloseClient(IClientAPI client)
        {
            //m_log.Info("PacketServer:CloseClient()");

            CloseCircuit(client.CircuitCode);
            m_scene.ClientManager.Remove(client.CircuitCode);
            client.Close(false);
        }