Skip to content

Commit

Permalink
Get new robot service before update
Browse files Browse the repository at this point in the history
  • Loading branch information
oysand committed Jun 27, 2024
1 parent 72c083f commit 6483c9f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ private async void OnIsarMissionUpdate(object? sender, MqttReceivedArgs mqttArgs
try
{
_updateRobotSemaphore.WaitOne();
await robotService.UpdateCurrentArea(robot.Id, null);
var newProviderToUpdateCurrentArea = GetServiceProvider(); // To ensure that the robot updates the other values correctly, it needs to get a new provider and service
var newRobotServiceToUpdateCurrentArea = newProviderToUpdateCurrentArea.GetRequiredService<IRobotService>();
await newRobotServiceToUpdateCurrentArea.UpdateCurrentArea(robot.Id, null);
_updateRobotSemaphore.Release();
}
catch (RobotNotFoundException)
Expand All @@ -355,7 +357,9 @@ private async void OnIsarMissionUpdate(object? sender, MqttReceivedArgs mqttArgs
try
{
_updateRobotSemaphore.WaitOne();
await robotService.UpdateCurrentMissionId(robot.Id, null);
var newProviderToUpdateCurrentMissionId = GetServiceProvider(); // To ensure that the robot updates the other values correctly, it needs to get a new provider and service
var newRobotServiceToUpdateCurrentMissionId = newProviderToUpdateCurrentMissionId.GetRequiredService<IRobotService>();
await newRobotServiceToUpdateCurrentMissionId.UpdateCurrentMissionId(robot.Id, null);
_updateRobotSemaphore.Release();
}
catch (RobotNotFoundException)
Expand Down

0 comments on commit 6483c9f

Please sign in to comment.