Created
May 6, 2016 08:40
-
-
Save zmactep/fd722ececd09bbb0f277c226c54baed6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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