Esempio n. 1
0
        public EventHandlerResult Handle(MqMessage <string> msg)
        {
            Console.WriteLine("FACE !!!");

            var model = JsonConvert.DeserializeObject <FaceDetectedEvent>(msg.Payload);

            var cmd = new IdentifyFaceCmd()
            {
                ImageId  = model.ImageId,
                ImageUrl = model.ImageUrl,
                X        = model.X,
                Y        = model.Y,
                Width    = model.Width,
                Height   = model.Height
            };

            IBasicProperties props = _client.Model.CreateBasicProperties();

            _client.Model.BasicPublish("msg_gateway", "vision.cmd.identify-face", true, props, RabbitMqMessageHelper.GetModelAsMessagePayload(cmd));

            _client.AckMessage(msg.DeliveryTag);

            return(new EventHandlerResult()
            {
                Success = true, MessageAcked = true
            });
        }
        public EventHandlerResult Handle(MqMessage <string> msg)
        {
            Console.WriteLine("Movement");

            var model = JsonConvert.DeserializeObject <MovementDetectedEvent>(msg.Payload);

            // send updates
            var detectface = new DetectFaceCmd()
            {
                ImageId  = model.ImageId,
                ImageUrl = model.ImageUrl,
                X        = model.X,
                Y        = model.Y,
                Width    = model.Width,
                Height   = model.Height
            };
            IBasicProperties props = _client.Model.CreateBasicProperties();

            _client.Model.BasicPublish("msg_gateway", "vision.cmd.detect-face", true, props, RabbitMqMessageHelper.GetModelAsMessagePayload(detectface));

            var detectbody = new DetectBodyCmd()
            {
                ImageId  = model.ImageId,
                ImageUrl = model.ImageUrl,
                X        = model.X,
                Y        = model.Y,
                Width    = model.Width,
                Height   = model.Height
            };

            _client.Model.BasicPublish("msg_gateway", "vision.cmd.detect-body", true, props, RabbitMqMessageHelper.GetModelAsMessagePayload(detectbody));
            _client.AckMessage(msg.DeliveryTag);

            return(new EventHandlerResult()
            {
                Success = true, MessageAcked = true
            });
        }