Exemple #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="offeredLocally">A value indicating whether this channel originated locally (as opposed to remotely).</param>
            /// <param name="id">The 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, bool offeredLocally, int id, OfferParameters offerParameters, ChannelOptions?channelOptions = null)
            {
                Requires.NotNull(multiplexingStream, nameof(multiplexingStream));
                Requires.NotNull(offerParameters, nameof(offerParameters));

                this.MultiplexingStream = multiplexingStream;
                this.offeredLocally     = offeredLocally;
                this.Id          = id;
                this.OfferParams = offerParameters;

                if (offeredLocally)
                {
                    this.localWindowSize = offerParameters.RemoteWindowSize;
                }
                else
                {
                    this.remoteWindowSize = offerParameters.RemoteWindowSize;
                }

                if (channelOptions == null)
                {
                    this.optionsAppliedTaskSource = new TaskCompletionSource <object?>();
                }
                else
                {
                    this.ApplyChannelOptions(channelOptions);
                }
            }
            internal Channel(MultiplexingStream multiplexingStream, int id, string name, ChannelOptions channelOptions)
            {
                Requires.NotNull(multiplexingStream, nameof(multiplexingStream));
                Requires.NotNull(channelOptions, nameof(channelOptions));
                Requires.NotNull(name, nameof(name));

                this.MultiplexingStream = multiplexingStream;
                this.Id          = id;
                this.Name        = name;
                this.TraceSource = channelOptions.TraceSource ?? new TraceSource($"{nameof(Streams.MultiplexingStream)}.{nameof(Channel)} {id} ({name})", SourceLevels.Critical);

                this.receivingPipe    = new Pipe();
                this.transmissionPipe = new Pipe();
                this.DisposeSelfOnFailure(this.ProcessOutboundTransmissionsAsync());
                this.DisposeSelfOnFailure(this.AutoCloseOnPipesClosureAsync());
            }
            /// <summary>
            /// Initializes a new instance of the <see cref="Channel"/> class.
            /// </summary>
            /// <param name="multiplexingStream">The owning <see cref="Streams.MultiplexingStream"/>.</param>
            /// <param name="offeredLocally">A value indicating whether this channel originated locally (as opposed to remotely).</param>
            /// <param name="id">The ID of the channel.</param>
            /// <param name="name">The name of the channel.</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, bool offeredLocally, int id, string name, ChannelOptions?channelOptions = null)
            {
                Requires.NotNull(multiplexingStream, nameof(multiplexingStream));
                Requires.NotNull(name, nameof(name));

                this.MultiplexingStream = multiplexingStream;
                this.offeredLocally     = offeredLocally;
                this.Id   = id;
                this.Name = name;

                if (channelOptions == null)
                {
                    this.optionsAppliedTaskSource = new TaskCompletionSource <object?>();
                }
                else
                {
                    this.ApplyChannelOptions(channelOptions);
                }
            }
Exemple #4
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);
                }
            }