public override void OnStreamAdded(IHttp2Stream stream)
        {
            int streamId = stream.Id;

            if (!_stateOnlyMap.TryGetValue(streamId, out State state))
            {
                state = new State(this, stream);
                // Only the stream which was just added will change parents. So we only need an array of size 1.
                List <ParentChangedEvent> events = new List <ParentChangedEvent>(1);
                _connectionState.TakeChild(state, false, events);
                NotifyParentChanged(events);
            }
            else
            {
                _             = _stateOnlyMap.Remove(streamId);
                _             = _stateOnlyRemovalQueue.TryRemove(state);
                state._stream = stream;
            }

            Http2StreamState streamState = stream.State;

            if (Http2StreamState.ReservedRemote == streamState || Http2StreamState.ReservedLocal == streamState)
            {
                state.SetStreamReservedOrActivated();
                // wasStreamReservedOrActivated is part of the comparator for stateOnlyRemovalQueue there is no
                // need to reprioritize here because it will not be in stateOnlyRemovalQueue.
            }

            _ = stream.SetProperty(_stateKey, state);
        }
Ejemplo n.º 2
0
            public override void ChannelActive(IChannelHandlerContext context)
            {
                var ch = (IHttp2StreamChannel)context.Channel;

                _stateOnActive = ch.Stream.State;
                _streamId      = ch.Stream.Id;
                base.ChannelActive(context);
            }
Ejemplo n.º 3
0
 /// <summary>
 /// Indicates whether the local side of this stream is open (i.e. the state is either
 /// <see cref="Http2StreamState.Open"/> or <see cref="Http2StreamState.HalfClosedRemote"/>.
 /// </summary>
 public static bool LocalSideOpen(this Http2StreamState state)
 {
     return(state switch
     {
         Http2StreamState.Idle => false,
         Http2StreamState.ReservedLocal => false,
         Http2StreamState.ReservedRemote => false,
         Http2StreamState.Open => true,
         Http2StreamState.HalfClosedLocal => false,
         Http2StreamState.HalfClosedRemote => true,
         Http2StreamState.Closed => false,
         _ => throw ThrowHelper.GetNotSupportedException(),
     });