Skip to content

Instantly share code, notes, and snippets.

@abreslav
Created February 27, 2013 08:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abreslav/5046126 to your computer and use it in GitHub Desktop.
Save abreslav/5046126 to your computer and use it in GitHub Desktop.
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