Not sure if this is the right approach, but I have the makings of a little
REPL as shown below (I know this guy will need a dedicated dispatcher).

The idea is that console input, including "exit" is sent to the parent
which would like to do a graceful shutdown. Is there a way in the parent to
kill this actor (which has already sent itself a ReadLine message, or do I
have to handle the "exit" input within this actor itself? I suppose the
latter is fine if I make the exit input a constructor parameter.

class ConsoleInputActor extends Actor {


  import ConsoleInputActor._


  def receive = {

    case EnableConsole => {

      context.become(acceptingUserInput)

      self ! ReadLine

    }

  }


  def acceptingUserInput: Receive = {

    case ReadLine => {

      val userInput = readLine("Prompt\n")

      context.parent ! MessageFromConsole(userInput)

      self ! ReadLine

    }

  }

}

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to