public Task Publish(CommandModel command) { var message = new MqttApplicationMessageBuilder() .WithTopic("BOILER_COMMAND/JSON") .WithPayload(JsonConvert.SerializeObject(command)) .Build(); return(mqttClientService.PublishAsync(message, CancellationToken.None)); }
public Task PublishAsync(string exchange, string typeName, byte[] body, CancellationToken cancellationToken = default) { var msg = new MqttApplicationMessage { Topic = exchange, ContentType = typeName, Payload = body }; return(_mqttClientService.PublishAsync(msg)); }
public async Task <string> ScheduleAsync(EmailMessage message, CancellationToken cancellationToken) { var context = _httpContextAccessor.HttpContext; if (context is null) { throw new InvalidOperationException($"Email scheduler is being invoked outside of request context."); } if (!context.User.Identity.IsAuthenticated) { throw new UnauthorizedException(); } var owner = context.User.FindFirstValue(OAuth2ClaimTypes.Ownership); if (string.IsNullOrEmpty(owner)) { throw new ForbiddenException($"Current user does not specify ownership."); } var messageId = await _mqttClientService.PublishAsync(new EmailMessageTask(message, owner), cancellationToken); return(messageId.HasValue ? messageId.Value.ToString() : string.Empty); }
// обновление документа public async Task UpdateFromUIAsync(Client client, Device device) { if (device.TypeOfDevice == "Light") { if (ConnectSingleton.IsConnected == false) { await _mqttClientService.ConnectAsync(client.Id); await _mqttClientService.SubscribeAsync(device.Topic); ConnectSingleton.getInstance(true); } var messagePayload = new MqttApplicationMessageBuilder() .WithTopic(device.Topic) .WithPayload(device.Payload) .WithExactlyOnceQoS() .WithRetainFlag() .Build(); await _mqttClientService.PublishAsync(messagePayload); } await Devices.ReplaceOneAsync(new BsonDocument("_id", new ObjectId(device.Id)), device); }
public async Task PublishAsync(string topic, string payload) { await _mqttClientService.PublishAsync(topic, payload); }
public async Task PublishToMqttBroker(string topic, string payload) { await mqttClientService.PublishAsync(topic, payload); }
public Task SendMessageToTopic([FromBody] string payload) { return(_mqttClient.PublishAsync(payload)); }
public void CatchThief() { AddMessageToConsole(Me, "Sending catch thief signal."); m_MqttClient.PublishAsync("suitceyes/kyd/CatchThief"); }