示例#1
0
        /// <summary>
        /// Sends an envelope to the connected node.
        /// </summary>
        /// <param name="envelope">Envelope to be transported</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override async Task SendAsync(Envelope envelope, CancellationToken cancellationToken)
        {
            UpdateSessionNegotiated(envelope);

            try
            {
                await _envelopePipe.SendAsync(envelope, cancellationToken);
            }
            catch (InvalidOperationException)
            {
                await CloseWithTimeoutAsync();

                throw;
            }
        }
        public override async Task SendAsync(Envelope envelope, CancellationToken cancellationToken)
        {
            EnsureOpen("send");

            try
            {
                EnsureOpen("send");
                await _envelopePipe.SendAsync(envelope, cancellationToken).ConfigureAwait(false);
            }
            catch (InvalidOperationException)
            {
                await CloseWithTimeoutAsync().ConfigureAwait(false);

                throw;
            }
        }