Exemple #1
0
        public async Task ConnectAsync(string userName, string password)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException("Username cannot be empty", nameof(userName));
            }

            UserName  = userName.ToLower();
            _password = password;

            await _client.ConnectAsync();
        }
Exemple #2
0
        /// <summary>
        /// Asynchronously establishes a connection with the peer.  The version is sent
        /// </summary>
        /// <returns></returns>
        public async Task ConnectAsync()
        {
            if (_client.IsConnected)
            {
                return;
            }

            await _client.ConnectAsync();

            // Before any other messages can be processed, need to send version
            SendMessage(new MsgVersion {
                ProtocolVersion = 1
            });

            // Fire off background task to process incoming requests
            _backgroundReadTask = new Task(ReadIncomingMessages, TaskCreationOptions.LongRunning);
            _backgroundReadTask.Start();
        }