Hi Arnout,thank you very much for your very clarifying answer, in the end I
opted to follow the first solution, completely abolishing the use of Ask,
following your advice, they are really ugly!
This is the result I got, it seems to work I've tested with some evidence
and it seems to serve players in the order set by the tickets.
This solution has allowed me to simplify very much the code, in my opinion
more readable, I post solution below:
*If the game is not finished i check the number on the ticket, if it's bot
the courrent position that the Oracle need, (starting with 1, then 2,...and
so on), will be stashed, otherwise, it will UnstashAll() the others, and
will be processed and send back to the sender, finally check the courrent
position, if it's = nPlayers, the counter will restart for a new turn.*
@Override
public void onReceive(Object message) throws Throwable {
if (!gameFinished) {
if (message instanceof Ticket) {
if (!gameFinished && ((Ticket) message).getPosition() == courrentTicket) {
unstashAll();
ResultMsg result = getResult(((Ticket) message));
isFound(result);
getSender().tell(result, ActorRef.noSender());
if (this.courrentTicket == this.nPlayers) {
this.courrentTicket = 1;
} else {
courrentTicket++;
}
} else {
stash();
}
}
} else {
throw new GameFinishedException();
}
}
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.