From ab7328301b2de6d1bade930a2ffd8f0be3dec9e3 Mon Sep 17 00:00:00 2001 From: Egor Rutkowski Date: Wed, 15 May 2024 15:07:01 +0200 Subject: [PATCH] =?UTF-8?q?AddressBook=20m=C3=BCsste=20jetzt=20richtig=20s?= =?UTF-8?q?ein?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/AddressBook.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/AddressBook.java b/src/main/java/com/example/AddressBook.java index 8f18efd..30e5a75 100644 --- a/src/main/java/com/example/AddressBook.java +++ b/src/main/java/com/example/AddressBook.java @@ -15,7 +15,7 @@ public class AddressBook extends AbstractBehavior { ArrayList> customers; public interface Message {} public record CustomerMessage(ActorRef fragender, String nameFragender) implements Message{} - public record Response(ActorRef addresse) implements Message{} + @Override public Receive createReceive() { @@ -33,12 +33,12 @@ public class AddressBook extends AbstractBehavior { customers = actors; } - //Methode, um einen zufälligen Empfänger auszugeben (wahrscheinlich das Senden am Ende noch nicht ganz richtig) + //Methode, um einen zufälligen Empfänger auszugeben public Behavior onCustomerMessage(CustomerMessage msg){ Collections.shuffle(customers); - var adressOf = customers.get(0); - getContext().getLog().info("{} asked for an adress",msg.nameFragender); - msg.fragender().tell((Customer.Message) new Response(adressOf).addresse); + var addressOf = customers.get(0); + getContext().getLog().info("{} asked for an address",msg.nameFragender); + msg.fragender.tell(new Customer.AddressMessage(addressOf)); return this; } }