Skip to content

Instantly share code, notes, and snippets.

@YusukeKokubo
Created January 10, 2013 15:38
Show Gist options
  • Save YusukeKokubo/4502927 to your computer and use it in GitHub Desktop.
Save YusukeKokubo/4502927 to your computer and use it in GitHub Desktop.
hello Akka on Scala 2.10.0
name := "hello Akka"
version := "0.0.1"
scalaVersion := "2.10.0"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.1.0"
import akka.actor._
class HogeActor extends Actor {
def receive = {
case i:Int => println("Int=" + i)
case hoge:Hoge => println("your name is " + hoge.name)
case _ => sender ! "received something."
}
}
sealed case class Hoge(name:String)
object Main extends App {
val system = ActorSystem("Hoge")
val hogeActor = system.actorOf(Props[HogeActor])
hogeActor ! 100
hogeActor ! "taro"
hogeActor ! Hoge("hoge")
hogeActor ! Hoge("yusuke")
val result = hogeActor ! "fooo"
println("get: " + result)
system.shutdown()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment