Пример #1
0
        /// <summary>
        /// Removes a queue from a server
        /// </summary>
        private async Task RemoveQueue(MqClient client, HorseMessage message)
        {
            HorseQueue queue = _server.FindQueue(message.Target);

            if (queue == null)
            {
                if (message.WaitResponse)
                {
                    await client.SendAsync(message.CreateResponse(HorseResultCode.NotFound));
                }
                return;
            }

            foreach (IAdminAuthorization authorization in _server.AdminAuthorizations)
            {
                bool grant = await authorization.CanRemoveQueue(client, queue);

                if (!grant)
                {
                    if (message.WaitResponse)
                    {
                        await client.SendAsync(message.CreateResponse(HorseResultCode.Unauthorized));
                    }

                    return;
                }
            }

            await _server.RemoveQueue(queue);

            if (message.WaitResponse)
            {
                await client.SendAsync(message.CreateResponse(HorseResultCode.Ok));
            }
        }