Hi,
There is a sample chat application inside the Play 2.2 bundle where there
is a single room.
I'm trying to implement the multiple room version of this sample.
In the original sample the there is only one actor managing the room which
is define as static. In my implementation I have created RoomManagerActor
which is defined as static.
The path of the RoomManagerActor is as follows:
*akka://application/user/MyRoomManager/test1*
When there is a Join request to a room, I "tell" the RoomManagerActor that
there is a join request. If the room actor identified with a name is not
created it is created as a child of RoomManager. For example the path of
the new room actor could be *akka://application/user/MyRoomManager/test1*(room
is named
*test1*) .
The code that handles the child creation inside RoomManagerActor is like
the following:
public void onReceive(Object message) throws Exception {
>
> if(message instanceof JoinRoom) {
> Logger.debug("MESSAGE: JoinRoom");
> JoinRoom messageJoinRoom = (JoinRoom)message;
> ActorRef roomActor = getContext().getChild(messageJoinRoom.roomTitle);
> Logger.debug("Found child actor : "+roomActor);
> if(roomActor == null) {
> roomActor = getContext().actorOf(Props.create(RoomActor.class,
> messageJoinRoom.roomTitle), messageJoinRoom.roomTitle);
> }
> Logger.debug("New Room Actor Path : "+ roomActor.path());
> RoomActor.Join join = new RoomActor.Join(messageJoinRoom.username,
> messageJoinRoom.channel);
> String result = (String)Await.result( ask(roomActor,join, 3000),
> Duration.create(3, SECONDS));
> Logger.debug("Room actor Join ask result : "+result);
> }
> }
I wonder if my method is the right approach for this? Sometimes I think
that RoomManagerActor is not so necessary.
Thanks.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> 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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.