AddressBook müsste jetzt richtig sein
This commit is contained in:
parent
fc6f611458
commit
ab7328301b
|
@ -15,7 +15,7 @@ public class AddressBook extends AbstractBehavior<AddressBook.Message> {
|
|||
ArrayList<ActorRef<Customer.Message>> customers;
|
||||
public interface Message {}
|
||||
public record CustomerMessage(ActorRef<Customer.Message> fragender, String nameFragender) implements Message{}
|
||||
public record Response(ActorRef<Customer.Message> addresse) implements Message{}
|
||||
|
||||
|
||||
@Override
|
||||
public Receive<AddressBook.Message> createReceive() {
|
||||
|
@ -33,12 +33,12 @@ public class AddressBook extends AbstractBehavior<AddressBook.Message> {
|
|||
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<Message> 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue