protected override async Task GivenASessionAsync( CancellationToken cancellationToken) { var synStreamSubscription = Server.On <SynStream>(); Server.On <GoAway>(); _stream = Session.Open(); await synStreamSubscription.ReceiveAsync(cancellationToken) .ConfigureAwait(false); await Server.SendAsync( SynReply.Accept(_stream.Id), cancellationToken) .ConfigureAwait(false); await Server.SendAsync( new Settings(Settings.InitialWindowSize(5)), cancellationToken) .ConfigureAwait(false); // Need to send something after settings in order to know when settings have been set Server.On <WindowUpdate>(); await Server.SendAsync( new Data( _stream.Id, Encoding.UTF8.GetBytes("dummy")), cancellationToken) .ConfigureAwait(false); await _stream.ReceiveAsync(cancellationToken : cancellationToken) .ConfigureAwait(false); }
protected override async Task GivenASessionAsync( CancellationToken cancellationToken) { Server.On <GoAway>(); var synStreamSubscription = Server.On <SynStream>(cancellationToken); _pingSubscription = Server.On <Ping>(cancellationToken); _stream = DisposeOnTearDown( Session.Open(options: SynStream.Options.Fin)); await synStreamSubscription.ReceiveAsync(cancellationToken) .ConfigureAwait(false); await Server.SendAsync( SynReply.Accept( _stream.Id, new NameValueHeaderBlock( ("header1", new[] { "Value1" }) )), cancellationToken) .ConfigureAwait(false); await Server.SendAsync( new Ping(0), cancellationToken) .ConfigureAwait(false); }
protected override Task GivenASessionAsync( CancellationToken cancellationToken) { Server.On <SynStream>(cancellationToken); Server.On <GoAway>(cancellationToken); _dataSubscription = Server.On <Data>(cancellationToken); _stream = Session.Open(); return(Task.CompletedTask); }
internal async Task <ReadResult> ReceiveAsync( SpdyStream stream, CancellationToken cancellationToken) { var readResult = await stream .ReceiveAsync( cancellationToken : cancellationToken) .ConfigureAwait(false); MessageReceived .AddRange( readResult.Buffer.Slice(0, readResult.Buffer.Length) .ToArray()); return(readResult); }
protected override async Task GivenASessionAsync( CancellationToken cancellationToken) { var synStreamSubscription = Server.On <SynStream>(); Server.On <GoAway>(); _stream = DisposeOnTearDown( Session.Open(options: SynStream.Options.Unidirectional | SynStream.Options.Fin)); await synStreamSubscription.ReceiveAsync(cancellationToken) .ConfigureAwait(false); await Server.SendAsync( SynReply.Accept(_stream.Id), cancellationToken) .ConfigureAwait(false); }
internal async ValueTask <bool> TrySendResponseAsync( SpdyStream stream, CancellationToken cancellationToken) { if (MessageReceived.Count == Request.Length) { foreach (var response in FragmentedResponses) { Encoding.ASCII.GetBytes(response) .CopyTo(Memory); await stream.SendAsync( Memory.Slice(0, response.Length), cancellationToken : cancellationToken) .ConfigureAwait(false); } return(true); } return(false); }
protected override async Task GivenASessionAsync( CancellationToken cancellationToken) { var synStreamSubscription = Server.On <SynStream>(cancellationToken); Server.On <GoAway>(cancellationToken); _windowUpdateSubscription = Server.On <WindowUpdate>(cancellationToken); _stream = Session.Open(); await synStreamSubscription.ReceiveAsync(cancellationToken) .ConfigureAwait(false); await Server.SendAsync( SynReply.Accept( _stream.Id), cancellationToken) .ConfigureAwait(false); await Server.SendAsync( Data.Last( _stream.Id, Encoding.UTF8.GetBytes("my data")), cancellationToken) .ConfigureAwait(false); }
internal static Task WaitForFullyClosedAsync( this SpdyStream stream, CancellationToken cancellationToken) => Task.WhenAll( stream.Local.WaitForClosedAsync(cancellationToken), stream.Remote.WaitForClosedAsync(cancellationToken));