private async void ProcessMessagesOnConnection(HybridConnectionStream connection, CancellationToken token) { try { try { try { while (!token.IsCancellationRequested) { IFeatureCollection features = await _featureSerializerManager.ReadAsync(connection, new[] { typeof(IHttpRequestFeature) }, token); PrepareDefaultFeatures(features); await _requestReceivedCallback(features, token); await _featureSerializerManager.WriteAsync(connection, features, new[] { typeof(IHttpResponseFeature) }, token); } } finally { await connection.ShutdownAsync(token); } } catch (IOException) { } catch (RelayException) { } } finally { await connection.CloseAsync(token); } }
public async Task SendRequestAsync(IFeatureCollection features, CancellationToken token) { await _featureSerializerManager.WriteAsync(_connection, features, new[] { typeof(IHttpRequestFeature) }, token); IFeatureCollection resultFeatures = await _featureSerializerManager.ReadAsync(_connection, new[] { typeof(IHttpResponseFeature) }, token); var resultHttpResponseFeature = resultFeatures.Get <IHttpResponseFeature>(); var httpResponseFeature = features.Get <IHttpResponseFeature>(); await CopyHttpResponseFeature(resultHttpResponseFeature, httpResponseFeature, token); }