Skip to content

Instantly share code, notes, and snippets.

@zmactep
Created May 6, 2016 08:40
Show Gist options
  • Save zmactep/fd722ececd09bbb0f277c226c54baed6 to your computer and use it in GitHub Desktop.
Save zmactep/fd722ececd09bbb0f277c226c54baed6 to your computer and use it in GitHub Desktop.
class Telnet extends Actor with ActorLogging {
override def receive : Receive = {
case Connected(remote, _) =>
log.info(s"Incoming connection from: $remote")
val handler = context.actorOf(Props[SimplisticHandler])
sender() ! Register(handler)
}
}
class SimplisticHandler extends Actor with ActorLogging {
def receive = {
case Received(data) =>
log.info("I have received something, answer is on the way")
sender() ! Write("Hello, ".map(_.toByte) ++ data)
case PeerClosed =>
log.info("Connection closed by peer")
context stop self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment