Add MQTT events
This commit is contained in:
parent
0b0b54c6af
commit
2866c12985
@ -232,7 +232,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
Configuration configurationModified = _configurationService.Update(updatedConfiguration.id, configuration);
|
Configuration configurationModified = _configurationService.Update(updatedConfiguration.id, configuration);
|
||||||
|
|
||||||
// TODO HANDLE MqttClientService.PublishMessage($"config/{configurationModified.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
MqttClientService.PublishMessage($"config/{configurationModified.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
||||||
|
|
||||||
List<string> sectionIds = _sectionService.GetAllIdsFromConfiguration(configuration.Id);
|
List<string> sectionIds = _sectionService.GetAllIdsFromConfiguration(configuration.Id);
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ namespace ManagerService.Controllers
|
|||||||
_deviceService.Update(device.Id, device);
|
_deviceService.Update(device.Id, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO MqttClientService.PublishMessage($"config/{id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true, isDeleted = true }));
|
MqttClientService.PublishMessage($"config/{id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true, isDeleted = true }));
|
||||||
|
|
||||||
return new ObjectResult("The configuration has been deleted") { StatusCode = 202 };
|
return new ObjectResult("The configuration has been deleted") { StatusCode = 202 };
|
||||||
|
|
||||||
|
|||||||
@ -242,7 +242,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
Device deviceModified = _deviceService.Update(device.Id, device);
|
Device deviceModified = _deviceService.Update(device.Id, device);
|
||||||
|
|
||||||
// TODO MqttClientService.PublishMessage($"player/{device.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
MqttClientService.PublishMessage($"player/{device.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
||||||
|
|
||||||
return new OkObjectResult(deviceModified.ToDTO());
|
return new OkObjectResult(deviceModified.ToDTO());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -533,7 +533,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
Section sectionModified = _sectionService.Update(updatedSection.id, section);
|
Section sectionModified = _sectionService.Update(updatedSection.id, section);
|
||||||
|
|
||||||
// TODO MqttClientService.PublishMessage($"config/{sectionModified.ConfigurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
MqttClientService.PublishMessage($"config/{sectionModified.ConfigurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
||||||
|
|
||||||
return new OkObjectResult(sectionModified.ToDTO());
|
return new OkObjectResult(sectionModified.ToDTO());
|
||||||
}
|
}
|
||||||
@ -582,7 +582,7 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updatedSectionsOrder.Count > 0) {
|
if (updatedSectionsOrder.Count > 0) {
|
||||||
// TODO MqttClientService.PublishMessage($"config/{updatedSectionsOrder[0].configurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
MqttClientService.PublishMessage($"config/{updatedSectionsOrder[0].configurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 };
|
return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 };
|
||||||
|
|||||||
@ -27,9 +27,9 @@ namespace Mqtt.Client.AspNetCore.Services
|
|||||||
|
|
||||||
public MqttClientService(IMqttClientOptions options)
|
public MqttClientService(IMqttClientOptions options)
|
||||||
{
|
{
|
||||||
var server = "localhost";
|
var server = "mymuseum.be";
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
server = "localhost";//"192.168.31.96";
|
server = "mymuseum.be";//"192.168.31.96";
|
||||||
#endif
|
#endif
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.options = new MqttClientOptionsBuilder()
|
this.options = new MqttClientOptionsBuilder()
|
||||||
@ -141,7 +141,7 @@ namespace Mqtt.Client.AspNetCore.Services
|
|||||||
.WithRetainFlag(false)
|
.WithRetainFlag(false)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
if (mqttClient.IsConnected)
|
if (mqttClient != null && mqttClient.IsConnected)
|
||||||
await mqttClient.PublishAsync(mqttMessage);
|
await mqttClient.PublishAsync(mqttMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ namespace ManagerService
|
|||||||
{
|
{
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
|
|
||||||
//MapConfiguration();
|
MapConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
@ -133,7 +133,7 @@ namespace ManagerService
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
//services.AddMqttClientHostedService();
|
services.AddMqttClientHostedService();
|
||||||
services.AddScoped(typeof(ProfileLogic));
|
services.AddScoped(typeof(ProfileLogic));
|
||||||
services.AddScoped<TokensService>();
|
services.AddScoped<TokensService>();
|
||||||
services.AddScoped<UserDatabaseService>();
|
services.AddScoped<UserDatabaseService>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user