Mercurial > hg > Members > anatofuz > akka-increment-sample
changeset 0:29ce0c93593f
init mercurial
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 29 Jan 2018 15:06:04 +0900 |
parents | |
children | 8c3460ff323a |
files | build.sbt src/main/scala/IncrementSample.scala |
diffstat | 2 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build.sbt Mon Jan 29 15:06:04 2018 +0900 @@ -0,0 +1,13 @@ +name := "increment-sample" + +version := "0.1" + +scalaVersion := "2.12.4" + +lazy val akkaVersion = "2.5.3" + +libraryDependencies ++= Seq( + "com.typesafe.akka" %% "akka-actor" % akkaVersion, + "com.typesafe.akka" %% "akka-testkit" % akkaVersion, + "org.scalatest" %% "scalatest" % "3.0.1" % "test" +)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/scala/IncrementSample.scala Mon Jan 29 15:06:04 2018 +0900 @@ -0,0 +1,38 @@ +package IncrementSample + + +import akka.actor.{Actor, ActorRef, ActorSystem, Props} + +object Incrementer { + def props: Props = Props[Incrementer] + +// final case class IncrementAndSend(data:Int, otherActor: ActorRef) + case object Print +} + +class Incrementer(printerActor: ActorRef) extends Actor { + import Incrementer._ + + /* + def IncrementAndSend = { + case IncrementAndSend(data,otherActor) => + otherActor ! IncrementAndSend(data,self) + + } + */ + + def receive = { + case IntData(data) => + incrementData(data) + } +} + +object IncrementSample extends App { + + import Incrementer._ + + + val system: ActorSystem = ActorSystem("incrementSample") + + val object1 :ActorRef = system.actorOf(Incrementer.props,"incrementActor") +}