Skip to content

Instantly share code, notes, and snippets.

@eodgooch
Created January 28, 2015 03:11
Show Gist options
  • Save eodgooch/b8959a52079e07426e0d to your computer and use it in GitHub Desktop.
Save eodgooch/b8959a52079e07426e0d to your computer and use it in GitHub Desktop.
ConsoleListener to add to our chap application
import akka.actor.Actor
/**
* Let's take a look at this to get an idea of how to open up a console window
* https://github.com/sdanzig/buddychat/blob/master/src/main/scala/scottdanzig/buddychat/actors/ConsoleActor.scala
*/
class KeyBoardListener extends Actor {
implicit ec = context.dispatcher
override def preStart() = {
}
def receive: Receive = {
case Start => setup()
case _ => throw new IllegalArgumentException("KeyBoardListener only Starts")
}
def setup(){
println("keyboard Running")
var line: String = ""
while (true) {
println("here")
line = Console.readLine()
context.actorSelection("..") ! line
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment