コード例 #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Channel"/> class.
            /// </summary>
            /// <param name="multiplexingStream">The owning <see cref="Streams.MultiplexingStream"/>.</param>
            /// <param name="channelId">The party-qualified ID of the channel.</param>
            /// <param name="offerParameters">The parameters of the channel from the offering party.</param>
            /// <param name="channelOptions">The channel options. Should only be null if the channel is created in response to an offer that is not immediately accepted.</param>
            internal Channel(MultiplexingStream multiplexingStream, QualifiedChannelId channelId, OfferParameters offerParameters, ChannelOptions?channelOptions = null)
            {
                Requires.NotNull(multiplexingStream, nameof(multiplexingStream));
                Requires.NotNull(offerParameters, nameof(offerParameters));

                this.MultiplexingStream = multiplexingStream;
                this.channelId          = channelId;
                this.OfferParams        = offerParameters;

                switch (channelId.Source)
                {
                case ChannelSource.Local:
                    this.localWindowSize = offerParameters.RemoteWindowSize;
                    break;

                case ChannelSource.Remote:
                    this.remoteWindowSize = offerParameters.RemoteWindowSize;
                    break;

                case ChannelSource.Seeded:
                    this.remoteWindowSize = offerParameters.RemoteWindowSize;
                    this.localWindowSize  = offerParameters.RemoteWindowSize;
                    break;

                default:
                    throw new NotSupportedException();
                }

                if (channelOptions == null)
                {
                    this.optionsAppliedTaskSource = new TaskCompletionSource <object?>();
                }
                else
                {
                    this.ApplyChannelOptions(channelOptions);
                }
            }
コード例 #2
0
            protected FrameHeader CreateFrameHeader(ControlCode code, ulong?channelId, ChannelSource?channelSource)
            {
                QualifiedChannelId?qualifiedId = null;

                if (channelId.HasValue)
                {
                    if (!channelSource.HasValue)
                    {
                        Assumes.True(this.IsOddEndpoint.HasValue);
                        bool channelIsOdd = channelId.Value % 2 == 1;

                        // Remember that this is from the remote sender's point of view.
                        channelSource = channelIsOdd == this.IsOddEndpoint.Value ? ChannelSource.Remote : ChannelSource.Local;
                    }

                    qualifiedId = new QualifiedChannelId(channelId.Value, channelSource.Value);
                }

                return(new FrameHeader
                {
                    Code = code,
                    ChannelId = qualifiedId,
                });
            }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChannelOfferEventArgs"/> class.
 /// </summary>
 /// <param name="id">The unique ID of the channel.</param>
 /// <param name="name">The name of the channel.</param>
 /// <param name="isAccepted">A value indicating whether the channel has already been accepted.</param>
 internal ChannelOfferEventArgs(QualifiedChannelId id, string name, bool isAccepted)
 {
     this.QualifiedId = id;
     this.Name        = name;
     this.IsAccepted  = isAccepted;
 }