示例#1
0
        internal async Task <bool> InternalConnect(string hostname, bool throwOnError = true)
        {
            if (LogAdapter.ExtendedLogEnabled)
            {
                LogAdapter.LogDebug(LogSource, "Trying to connect to " + hostname);
            }

            var result = await _io.InternalDoConnectSocket(hostname, _connectionInfo.port, throwOnError).ConfigureAwait(false);

            if (!result)
            {
                return(false);
            }

            result = await _io.Handshake(_connectionInfo.vhost,
                                         _connectionInfo.username,
                                         _connectionInfo.password,
                                         _connectionInfo.connectionName, _connectionInfo.heartbeat, throwOnError).ConfigureAwait(false);

            if (result && this.Recovery != null)
            {
                this.Recovery.NotifyConnected(hostname);
            }

            if (_connectionInfo.heartbeat != 0)
            {
                SetupHeartbeat(_connectionInfo.heartbeat);
            }

            return(result);
        }
示例#2
0
        internal async Task Connect(string hostname, string vhost, string username, string password, int port = 5672)
        {
            await _io.InternalDoConnectSocket(hostname, port);

            await _io.Handshake(vhost, username, password);
        }