Update TamagotchiService.java
This commit is contained in:
parent
3d2faac24a
commit
c123ff8ac0
1 changed files with 4 additions and 1 deletions
|
@ -84,8 +84,8 @@ public class TamagotchiService {
|
||||||
.parallelStream()
|
.parallelStream()
|
||||||
.filter(device -> !device.isAlive())
|
.filter(device -> !device.isAlive())
|
||||||
.forEach(device -> {
|
.forEach(device -> {
|
||||||
deviceRegistry.remove(device.getId());
|
|
||||||
sendTamagotchiDefunctNotifiction(device.getId());
|
sendTamagotchiDefunctNotifiction(device.getId());
|
||||||
|
deviceRegistry.remove(device.getId());
|
||||||
LOGGER.info("{} has died", device.getId());
|
LOGGER.info("{} has died", device.getId());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,9 @@ public class TamagotchiService {
|
||||||
private void sendTamagotchiDefunctNotifiction(String id) {
|
private void sendTamagotchiDefunctNotifiction(String id) {
|
||||||
|
|
||||||
Device device = deviceRegistry.get(id);
|
Device device = deviceRegistry.get(id);
|
||||||
|
if (device == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String defunctMessage = String.format("Tamagotchi %s of %s passed away", device.getOwner(), device.getOwner());
|
String defunctMessage = String.format("Tamagotchi %s of %s passed away", device.getOwner(), device.getOwner());
|
||||||
DefunctNotification defunctNotification = new DefunctNotification(defunctMessage);
|
DefunctNotification defunctNotification = new DefunctNotification(defunctMessage);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue