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;
|
ArrayList<ActorRef<Customer.Message>> customers;
|
||||||
public interface Message {}
|
public interface Message {}
|
||||||
public record CustomerMessage(ActorRef<Customer.Message> fragender, String nameFragender) implements Message{}
|
public record CustomerMessage(ActorRef<Customer.Message> fragender, String nameFragender) implements Message{}
|
||||||
public record Response(ActorRef<Customer.Message> addresse) implements Message{}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Receive<AddressBook.Message> createReceive() {
|
public Receive<AddressBook.Message> createReceive() {
|
||||||
|
@ -33,12 +33,12 @@ public class AddressBook extends AbstractBehavior<AddressBook.Message> {
|
||||||
customers = actors;
|
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){
|
public Behavior<Message> onCustomerMessage(CustomerMessage msg){
|
||||||
Collections.shuffle(customers);
|
Collections.shuffle(customers);
|
||||||
var adressOf = customers.get(0);
|
var addressOf = customers.get(0);
|
||||||
getContext().getLog().info("{} asked for an adress",msg.nameFragender);
|
getContext().getLog().info("{} asked for an address",msg.nameFragender);
|
||||||
msg.fragender().tell((Customer.Message) new Response(adressOf).addresse);
|
msg.fragender.tell(new Customer.AddressMessage(addressOf));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue