Exemple #1
0
        public void SubscribeToLightMeasuredEvent(Streetlight streetlight, int lumens)
        {
            var lightMeasuredEvent = new LightMeasuredEvent
            {
                Id     = streetlight.Id,
                Lumens = lumens,
                SentAt = DateTime.Now,
            };
            var payload = JsonConvert.SerializeObject(lightMeasuredEvent);

            // Simulate subscribing to a channel.
            // In reality this would call some kind of pub/sub client library to subscribe.
            // e.g. amqpClient.BasicConsume(LightMeasuredTopic, ...);
            _logger.LogInformation("Subscribing to {Topic} with payload {Payload} ", payload, SubscribeLightMeasuredTopic);
        }
Exemple #2
0
        public void SubscribeToLightMeasuredEvent(Streetlight streetlight, int lumens)
        {
            var lightMeasuredEvent = new LightMeasuredEvent
            {
                Id     = streetlight.Id,
                Lumens = lumens,
                SentAt = DateTime.Now,
            };
            var payload = JsonConvert.SerializeObject(lightMeasuredEvent);

            // Simulate publishing a message to the channel.
            // In reality this would call some kind of pub/sub client library and publish.
            // e.g. mqttClient.PublishAsync(message);
            // e.g. amqpClient.BasicPublish(LightMeasuredTopic, routingKey, props, payloadBytes);
            _logger.LogInformation("Subscribing to {Topic} with payload {Payload} ", payload, SubscribeLightMeasuredTopic);
        }
Exemple #3
0
 public Streetlight Add([FromBody] Streetlight streetlight)
 {
     streetlight.Id = StreetlightSeq++;
     StreetlightDatabase.Add(streetlight);
     return(streetlight);
 }