Example #1
0
        /// <summary>
        /// Sends negative ack or failed response if client is pending ack or response
        /// </summary>
        private static Task SendResponse(RouterPublishResult result, MqClient client, HorseMessage message)
        {
            if (result == RouterPublishResult.OkAndWillBeRespond)
            {
                return(Task.CompletedTask);
            }

            bool positive = result == RouterPublishResult.OkWillNotRespond;

            if (message.WaitResponse)
            {
                HorseMessage response = positive
                                            ? message.CreateAcknowledge()
                                            : message.CreateResponse(HorseResultCode.NotFound);

                return(client.SendAsync(response));
            }

            return(Task.CompletedTask);
        }