mandubian/play-actor-room

fromId sent in each message Received(fromId, payload)

Closed this issue · 2 comments

Not very important here, but as 1 receiver actor stands always for 1 member, why does his id from is included in each message Received(from, payload) instead of being an attribute of the actor itself?

Something like

// In room.scala
abstract class Receiver(id: String) extends Actor

// In the user file
class MyReceiver(id: String) extends Receiver(id) {
  override def receive = {
    case Received(payload) => ...
  }
}

It may be clearer (at the beginning I thought that from in Received(from, payload) could change). What do you think?

Yes I know... This is a choice that can be discussed...
Actually I wanted my Receiver to be a pure Actor and not a class of actor-room so that people just have to care about the kind of message to manage... If I created a Receiver(id: String) class, I'd go to a typed actor instead of a simple actor but I'm not a fan of typed actor for now...
I also wanted all messages to be self-sufficient containing all required info to know its origin and its target and its payload...

WDYT?

Ok, I understand ;)

I'll close the issue.