Created
January 10, 2013 15:38
-
-
Save YusukeKokubo/4502927 to your computer and use it in GitHub Desktop.
hello Akka on Scala 2.10.0
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
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" | |
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
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