Created
February 27, 2013 08:05
-
-
Save abreslav/5046126 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
package sample.hello | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
import akka.actor.UntypedActor | |
import akka.actor.UntypedActorContext | |
import akka.actor.ActorPath | |
import scala.concurrent.duration.Duration | |
import java.util.HashMap | |
import akka.actor.ActorSystem | |
import akka.actor.ActorRef | |
object start {} | |
fun main(args: Array<String>) { | |
val system = ActorSystem.create(); | |
val helloActor = system.actorOf(Props(javaClass<HelloActor>())); | |
helloActor.tell(start) | |
} | |
class HelloActor: UntypedActor() { | |
var worldActor: ActorRef = getContext().actorOf(Props(javaClass<WorldActor>())) | |
public override fun onReceive(msg: Any?) { | |
when (msg) { | |
start -> worldActor.tell("Hello", self()) | |
is String-> { | |
println("Received message: $msg") | |
getContext().system().shutdown() | |
} | |
else -> unhandled(msg) | |
} | |
} | |
} | |
class WorldActor: UntypedActor() { | |
public override fun onReceive(msg: Any?) { | |
when (msg) { | |
is String -> getSender().tell(msg.toUpperCase() + " world"); | |
else -> unhandled(msg); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment