Esempio n. 1
0
        private void _consumer_Received(IBasicConsumer sender, BasicDeliverEventArgs args)
        {
            var              payload = JObject.Parse(Encoding.UTF8.GetString(args.Body));
            string           token   = null;
            IBasicProperties props   = args.BasicProperties;

            uint expiry = 0;

            if (payload == null ||
                !props.IsHeadersPresent() ||
                string.IsNullOrWhiteSpace((token = props.GetStringHeader("device-token"))) ||
                !uint.TryParse(props.GetStringHeader("expiry"), out expiry))
            {
                // the message is too incomplete to handle
                this.Model.BasicNack(args.DeliveryTag, false, false);
                return;
            }
            _queue.Enqueue(new NotificationEventArgs(this, token, expiry, payload, args.DeliveryTag));
            _wait.Set();
        }