Пример #1
0
        /// <summary>
        /// Replies to this envelope.
        /// </summary>
        /// <param name="body">The body.</param>
        /// <param name="headers">The headers.</param>
        /// <returns></returns>
        public Task ReplyAsync(byte[] body, IDictionary <string, object> headers = null)
        {
            // validate arguments
            if (body == null)
            {
                throw new ArgumentNullException(nameof(body), "The body cannot be null");
            }
            else if (ID == Guid.Empty || ReplyTo == null)
            {
                throw new InvalidOperationException("The envelope does not have sufficient reply information");
            }

            if (_channel != null)
            {
                return(_channel.ReplyAsync(body, headers ?? new Dictionary <string, object>(StringComparer.CurrentCultureIgnoreCase)));
            }
            else
            {
                return(_node.ReplyAsync(ReplyTo, ID, body, headers ?? new Dictionary <string, object>(StringComparer.CurrentCultureIgnoreCase)));
            }
        }