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)); }
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); }
public void Connected(HttpOwinHostContext hostContext) { _owinHostContext.TrySetResult(hostContext); _taskScope.SetReady(); }
public void Connected(HttpOwinHostContext hostContext) { _owinHostContext.TrySetResult(hostContext); _taskScope.SetReady(); }