Ejemplo n.º 1
0
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        public XmppConnection(XMPPAccount account) : base(account)
        {
            TCP_CONNECTION = new TcpConnection(account);
            TCP_CONNECTION.ConnectionStateChanged += TcpConnection_ConnectionStateChanged;
            TCP_CONNECTION.NewDataReceived        += TCP_CONNECTION_NewDataReceived;

            GENERAL_COMMAND_HELPER = new GeneralCommandHelper(this);
            MUC_COMMAND_HELPER     = new MUCCommandHelper(this);
            PUB_SUB_COMMAND_HELPER = new PubSubCommandHelper(this);
            OMEMO_COMMAND_HELPER   = new OmemoCommandHelper(this);
            DISCO_HELPER           = new DiscoFeatureHelper(this);

            // The order in which new messages should get processed (TLS -- SASL -- Stream Management -- Resource binding -- ...).
            // https://xmpp.org/extensions/xep-0170.html
            //-------------------------------------------------------------
            // TLS:
            MESSAGE_PROCESSORS[0] = new TLSConnection(TCP_CONNECTION, this);

            // SASL:
            MESSAGE_PROCESSORS[1] = new SASLConnection(TCP_CONNECTION, this);

            // XEP-0198 (Stream Management):
            MESSAGE_PROCESSORS[2] = new SMConnection(TCP_CONNECTION, this);

            // Resource binding:
            RecourceBindingConnection recourceBindingConnection = new RecourceBindingConnection(TCP_CONNECTION, this);

            recourceBindingConnection.ResourceBound += RecourceBindingConnection_ResourceBound;
            MESSAGE_PROCESSORS[3] = recourceBindingConnection;
            //-------------------------------------------------------------

            NetworkHelper.Instance.NetworkChanged += Instance_NetworkChanged;
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        /// <summary>
        /// Basic Constructor
        /// </summary>
        /// <history>
        /// 05/05/2018 Created [Fabian Sauter]
        /// </history>
        public XMPPConnection2(XMPPAccount account) : base(account)
        {
            holdConnection       = false;
            connectionErrorCount = 0;
            lastConnectionError  = null;
            TCP_CONNECTION       = new TCPConnection2(account);
            TCP_CONNECTION.ConnectionStateChanged += TCPConnection_ConnectionStateChanged;
            TCP_CONNECTION.NewDataReceived        += TCPConnection_NewDataReceived;

            PARSER             = new MessageParser2();
            MESSAGE_PROCESSORS = new AbstractMessageProcessor[4];
            streamId           = null;
            messageIdCache     = new TSTimedList <string>();

            connectionTimer    = null;
            reconnectRequested = false;
            timeout            = TimeSpan.FromMilliseconds(CONNECTION_TIMEOUT);

            GENERAL_COMMAND_HELPER = new GeneralCommandHelper(this);
            MUC_COMMAND_HELPER     = new MUCCommandHelper(this);
            PUB_SUB_COMMAND_HELPER = new PubSubCommandHelper(this);
            OMEMO_COMMAND_HELPER   = new OmemoCommandHelper(this);

            // The order in which new messages should get processed (TLS -- SASL -- Stream Management -- Resource binding -- ...).
            // https://xmpp.org/extensions/xep-0170.html
            //-------------------------------------------------------------
            // TLS:
            MESSAGE_PROCESSORS[0] = new TLSConnection(TCP_CONNECTION, this);

            // SASL:
            MESSAGE_PROCESSORS[1] = new SASLConnection(TCP_CONNECTION, this);

            // XEP-0198 (Stream Management):
            MESSAGE_PROCESSORS[2] = new SMConnection(TCP_CONNECTION, this);

            // Resource binding:
            RecourceBindingConnection recourceBindingConnection = new RecourceBindingConnection(TCP_CONNECTION, this);

            recourceBindingConnection.ResourceBound += RecourceBindingConnection_ResourceBound;
            MESSAGE_PROCESSORS[3] = recourceBindingConnection;
            //-------------------------------------------------------------

            NetworkHelper.Instance.NetworkChanged += Instance_NetworkChanged;

            omemoHelper          = null;
            DISCO_FEATURE_HELPER = new DiscoFeatureHelper(this);
        }
Ejemplo n.º 3
0
 public ScramSHA1SASLMechanism(string id, string password, string clientNonceBase64, SASLConnection saslConnection) : base(id, password, saslConnection)
 {
     PASSWORD_NORMALIZED  = password.Normalize();
     CLIENT_NONCE_BASE_64 = clientNonceBase64;
     serverNonce          = null;
     saltBase64           = null;
     clientFirstMsg       = null;
     serverFirstMsg       = null;
 }
Ejemplo n.º 4
0
 //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
 #region --Constructors--
 /// <summary>
 /// Basic Constructor
 /// </summary>
 /// <history>
 /// 22/08/2017 Created [Fabian Sauter]
 /// </history>
 public ScramSHA1SASLMechanism(string id, string password, SASLConnection saslConnection) : this(id, password, CryptographicBuffer.EncodeToBase64String(CryptographicBuffer.GenerateRandom(CLIENT_NONCE_LENGTH)), saslConnection)
 {
 }
Ejemplo n.º 5
0
 public ScramSHA256SASLMechanism(string id, string password, string clientNonceBase64, SASLConnection saslConnection) : base(id, password, clientNonceBase64, saslConnection)
 {
 }
Ejemplo n.º 6
0
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--


        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        public ScramSHA256SASLMechanism(string id, string password, SASLConnection saslConnection) : base(id, password, saslConnection)
        {
        }
Ejemplo n.º 7
0
 //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
 #region --Constructors--
 /// <summary>
 /// Basic Constructor
 /// </summary>
 /// <history>
 /// 22/08/2017 Created [Fabian Sauter]
 /// </history>
 protected AbstractSASLMechanism(string id, string password, SASLConnection saslConnection)
 {
     this.ID              = id;
     this.PASSWORD        = password;
     this.SASL_CONNECTION = saslConnection;
 }
Ejemplo n.º 8
0
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--


        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        /// <summary>
        /// Basic Constructor
        /// </summary>
        /// <history>
        /// 24/08/2017 Created [Fabian Sauter]
        /// </history>
        public PlainSASLMechanism(string id, string password, SASLConnection saslConnection) : base(id, password, saslConnection)
        {
        }