예제 #1
0
        Task SendUsingNewConnection(IPipe <OwinHostContext> connectionPipe, OwinHostScope scope, CancellationToken stoppingToken)
        {
            try
            {
                if (_cacheTaskScope.StoppingToken.IsCancellationRequested)
                {
                    throw new TaskCanceledException($"The connection is being disconnected: {_settings.ToDebugString()}");
                }

                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Connecting: {0}", _settings.ToDebugString());
                }

                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Connected: {0} (address: {1}, local: {2}", _settings.ToDebugString(),
                                     _settings.Host, _settings.Port);
                }

                var hostContext = new HttpOwinHostContext(_settings, _cacheTaskScope);

                hostContext.GetOrAddPayload(() => _settings);

                scope.Connected(hostContext);
            }
            catch (Exception ex)
            {
                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw new HttpConnectionException("Connect failed: " + _settings.ToDebugString(), ex);
            }

            return(SendUsingExistingConnection(connectionPipe, scope, stoppingToken));
        }
예제 #2
0
        Task SendUsingNewConnection(IPipe<OwinHostContext> connectionPipe, OwinHostScope scope, CancellationToken stoppingToken)
        {
            try
            {
                if (_cacheTaskScope.StoppingToken.IsCancellationRequested)
                    throw new TaskCanceledException($"The connection is being disconnected: {_settings.ToDebugString()}");

                if (_log.IsDebugEnabled)
                    _log.DebugFormat("Connecting: {0}", _settings.ToDebugString());
                
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Connected: {0} (address: {1}, local: {2}", _settings.ToDebugString(),
                        _settings.Host, _settings.Port);
                }

                var hostContext = new HttpOwinHostContext(_settings, _cacheTaskScope);

                hostContext.GetOrAddPayload(() => _settings);

                scope.Connected(hostContext);
            }
            catch (Exception ex)
            {
                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw new HttpConnectionException("Connect failed: " + _settings.ToDebugString(), ex);
            }

            return SendUsingExistingConnection(connectionPipe, scope, stoppingToken);
        }
예제 #3
0
            public void Connected(HttpOwinHostContext hostContext)
            {
                _owinHostContext.TrySetResult(hostContext);

                _taskScope.SetReady();
            }
예제 #4
0
            public void Connected(HttpOwinHostContext hostContext)
            {
                _owinHostContext.TrySetResult(hostContext);

                _taskScope.SetReady();
            }