Exemplo n.º 1
0
 /// <summary>
 /// Listens for connections from the XMPP server and is used for components only.
 /// </summary>
 protected virtual void Accept()
 {
     if ((m_stanzas == null) || (!m_stanzas.Acceptable))
         m_stanzas = StanzaStream.Create(this.ConnectionType, this);
     lock (StateLock)
     {
         this.State = AcceptingState.Instance;
         m_reconnect = ((int)this[Options.RECONNECT_TIMEOUT] >= 0);
     }
     m_stanzas.Accept();
 }
Exemplo n.º 2
0
        public void Closed()
        {
            lock (StateLock)
            {
                State = ClosedState.Instance;
                if ((m_stanzas != null) && (!m_stanzas.Acceptable))
                    m_stanzas = null;
                m_sslOn = false;
                m_compressionOn = false;
            }

            if (OnDisconnect != null)
            {
                OnDisconnect(this);
            }

            TryReconnect();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Starts connecting to the XMPP server.  This is done asyncronously.
        /// </summary>
        public virtual void Connect()
        {
            // Cannot connect when we have an open
            if (m_stanzas != null && m_stanzas.Connected)
            {
                throw new Exception("Cannot connect - stream is already connected!");
            }

            this[Options.CURRENT_KEEP_ALIVE] = -1;
            m_stanzas = StanzaStream.Create(this.ConnectionType, this);
            lock (StateLock)
            {
                State = ConnectingState.Instance;
                m_reconnect = ((int)this[Options.RECONNECT_TIMEOUT] >= 0);
            }
            m_stanzas.Connect();
        }
Exemplo n.º 4
0
        public void Errored(Exception ex)
        {
            m_reconnect = false;

            lock (m_stateLock)
            {
                State = ClosedState.Instance;
                if ((m_stanzas != null) && (!m_stanzas.Acceptable))
                    m_stanzas = null;
            }

            if (OnError != null)
            {
                OnError(this, ex);
            }

            // TODO: Figure out what the "good" errors are, and try to
            // reconnect.  There are too many "bad" errors to just let this fly.
            //TryReconnect();
        }