Esempio n. 1
0
        public void PublishLightMeasurement(LightMeasuredEvent lightMeasuredEvent)
        {
            var payload = JsonSerializer.Serialize(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);
            _logger.LogInformation("Publishing message {Payload} to test.mosquitto.org/{Topic}", payload, SubscribeLightMeasuredTopic);
        }
Esempio n. 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 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);
        }
Esempio n. 3
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);
        }