コード例 #1
0
ファイル: MqClient.cs プロジェクト: Gdegdevalera/GlimpseTest
 public void Publish(ImageUploadedMessage message)
 {
     _channel.BasicPublish(
         exchange: string.Empty, // direct exchange
         routingKey: _queueName,
         body: Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)));
 }
コード例 #2
0
        public async Task <ImageUploadedMessage> Handle(Stream imageStream)
        {
            var(imageId, uploadedOn) = await _storage.Save(imageStream);

            var message = new ImageUploadedMessage
            {
                ImageId    = imageId,
                UploadedOn = uploadedOn
            };

            _mqClient.Publish(message);
            return(message);
        }
コード例 #3
0
        public ImageRecognizedMessage OnImageUploaded(ImageUploadedMessage message)
        {
            var bytes = _storage.ReadFile(message.ImageId);

            if (bytes == null)
            {
                return(null);
            }

            return(new ImageRecognizedMessage
            {
                ImageId = message.ImageId,
                UploadedOn = message.UploadedOn,
                Categories = _recognizer.GetCategories(bytes)
            });
        }