private void Load(string connectionString)
        {
            string[] keyPairs = connectionString.Split(';');

            if (options != null)
            {
                options.Clear();
            }

            foreach (string keyPair in keyPairs)
            {
                string[] values = keyPair.Split('=');

                if (values.Length == 2 &&
                    values[0] != null && values[0].Length > 0 &&
                    values[1] != null && values[1].Length > 0)
                {
                    values[0] = values[0].ToLower(CultureInfo.CurrentUICulture);

                    if (XmppConnectionString.IsSynonym(values[0]))
                    {
                        options[XmppConnectionString.GetSynonym(values[0])] = values[1].Trim();
                    }
                }
            }
        }
        /// <summary>
        ///   Disposes the specified disposing.
        /// </summary>
        /// <param name = "disposing">if set to <c>true</c> [disposing].</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    Close();
                }

                userId           = null;
                connectionString = null;
                SyncReads        = null;
                SyncWrites       = null;

                onMessageReceivedSubject       = null;
                onXmppStreamInitializedSubject = null;
                onXmppStreamClosedSubject      = null;

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
            }

            IsDisposed = true;
        }
Exemple #3
0
        /// <summary>
        /// Disposes the specified disposing.
        /// </summary>
        /// <param name="disposing">if set to <c>true</c> [disposing].</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!this.isDisposed)
            {
                if (disposing)
                {
                    this.Close();
                }

                this.connectionString = null;

                if (this.messageStream != null)
                {
                    this.messageStream.Dispose();
                    this.messageStream = null;
                }

                if (this.stateChanged != null)
                {
                    this.stateChanged.Dispose();
                    this.stateChanged = null;
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
            }

            this.isDisposed = true;
        }
Exemple #4
0
        /// <summary>
        /// Opens the connection
        /// </summary>
        /// <param name="connectionString">The connection string used for authentication.</param>
        public override async Task OpenAsync(XmppConnectionString connectionString
                                             , IList <ChainValidationResult> ignorableServerCertificateErrors)
        {
            Debug.WriteLine($"TRANSPORT => Opening connection against hostname {connectionString.HostName}");

            this.PublishStateChange(TransportState.Opening);

            // Update the list of ignorable server SSL errors
            if (!ignorableServerCertificateErrors.IsEmpty())
            {
                this.ignorableServerCertificateErrors = ignorableServerCertificateErrors;
            }
            else
            {
                this.ignorableServerCertificateErrors = new List <ChainValidationResult>
                {
                    ChainValidationResult.InvalidName
                };
            }

            // Connection string
            this.ConnectionString = connectionString;

            // Connect to the server
            await this.ConnectAsync().ConfigureAwait(false);

            if (this.State != TransportState.ConnectionFailed)
            {
                this.PublishStateChange(TransportState.Open);

                // Initialize XMPP Stream
                await this.ResetStreamAsync().ConfigureAwait(false);
            }
        }
 public virtual void Close()
 {
     userId                         = null;
     connectionString               = null;
     SyncReads                      = null;
     SyncWrites                     = null;
     onMessageReceivedSubject       = null;
     onXmppStreamInitializedSubject = null;
     onXmppStreamClosedSubject      = null;
 }
Exemple #6
0
        /// <summary>
        ///   Opens the connection
        /// </summary>
        /// <param name = "connectionString">The connection string used for authentication.</param>
        public override void Open(XmppConnectionString connectionString)
        {
            // Connection string
            ConnectionString = connectionString;
            UserId           = ConnectionString.UserId;

            // Initialization
            Initialize();

            // Connect to the server
            Connect();

            // Begin Receiving Data
            BeginReceiveData();
        }
Exemple #7
0
        public virtual void Close()
        {
            if (this.messageStream != null)
            {
                this.messageStream.Dispose();
                this.messageStream = null;
            }

            if (this.stateChanged != null)
            {
                this.stateChanged.Dispose();
                this.stateChanged = null;
            }

            this.connectionString = null;
        }
Exemple #8
0
        public override void Open(XmppConnectionString connectionString) {
            // Connection string
            ConnectionString = connectionString;
            UserId = ConnectionString.UserId;

            // Generate initial RID
            var rng = new RNGCryptoServiceProvider();
            var bytes = new byte[32/8];

            rng.GetBytes(bytes);

            rid = BitConverter.ToInt32(bytes, 0);
            rid = (rid < 0) ? -rid : rid;

            // HTTP Configuration
            ServicePointManager.Expect100Continue = false;
            ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
        }
        public override void Open(XmppConnectionString connectionString)
        {
            // Connection string
            ConnectionString = connectionString;
            UserId           = ConnectionString.UserId;

            // Generate initial RID
            var rng   = new RNGCryptoServiceProvider();
            var bytes = new byte[32 / 8];

            rng.GetBytes(bytes);

            rid = BitConverter.ToInt32(bytes, 0);
            rid = (rid < 0) ? -rid : rid;

            // HTTP Configuration
            ServicePointManager.Expect100Continue = false;
            ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
        }
Exemple #10
0
 public abstract Task OpenAsync(XmppConnectionString connectionString
                                , IList <ChainValidationResult> ignorableServerCertificateErrors);
Exemple #11
0
        /// <summary>
        ///   Disposes the specified disposing.
        /// </summary>
        /// <param name = "disposing">if set to <c>true</c> [disposing].</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    Close();
                }

                userId = null;
                connectionString = null;
                SyncReads = null;
                SyncWrites = null;

                onMessageReceivedSubject = null;
                onXmppStreamInitializedSubject = null;
                onXmppStreamClosedSubject = null;

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
            }

            IsDisposed = true;
        }
Exemple #12
0
 public abstract void Open(XmppConnectionString connectionString);
Exemple #13
0
 public virtual void Close()
 {
     userId = null;
     connectionString = null;
     SyncReads = null;
     SyncWrites = null;
     onMessageReceivedSubject = null;
     onXmppStreamInitializedSubject = null;
     onXmppStreamClosedSubject = null;
 }
Exemple #14
0
        /// <summary>
        /// Opens the connection
        /// </summary>
        /// <param name="connectionString">The connection string used for authentication.</param>
        public override void Open(XmppConnectionString connectionString)
        {
            // Connection string
            this.ConnectionString   = connectionString;
            this.UserId             = this.ConnectionString.UserId;

            // Initialization
            this.Initialize();

            // Connect to the server
            this.Connect();

            // Begin Receiving Data
            this.BeginReceiveData();
        }
 public abstract void Open(XmppConnectionString connectionString);
 /// <summary>
 /// Initializes a new instance of the <see cref="T:SaslDigestMechanism"/> class.
 /// </summary>
 public SaslDigestMechanism(XmppConnectionString connectionString)
 {
     this.connectionString = connectionString;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:SaslPlainMechanism"/> class.
 /// </summary>
 public SaslPlainMechanism(XmppConnectionString connectionString)
 {
     this.connectionString = connectionString;
 }
Exemple #18
0
        /// <summary>
        ///   Opens the connection
        /// </summary>
        /// <param name = "connectionString">The connection string used for authentication.</param>
        public override void Open(XmppConnectionString connectionString)
        {
            // Connection string
            ConnectionString = connectionString;
            UserId = ConnectionString.UserId;

            // Initialization
            Initialize();

            // Connect to the server
            Connect();

            // Begin Receiving Data
            BeginReceiveData();
        }
Exemple #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:SaslScramSha1Mechanism"/> class.
 /// </summary>
 public SaslScramSha1Mechanism(XmppConnectionString connectionString)
 {
     this.connectionString = connectionString;
 }