Scala で Akka を操作する方法を理解しようとしています。私はそれを正しく理解しましたか、私がする必要があるのはこれの代わりです:
class Class1 {
def someMethod1 = {
//.... some operations....
"someStringData"
}
def someMethod2(param1: Int, param2: Double, param3: BigInt) = {
//.... some operations....
new someClass
}
}
//.............................
object Application extends App {
val c = new Class1
val stringData = c.someMethod1
val someClass = c.someMethod2
}
私はこれをしなければなりません:
case object SomeMethod
case class SomeClass(a: Int, b: Double, c: BigInt)
case class SomeReturnClass(d: Boolean)
class Class1 extends Actor{
def receive = {
case SomeMethod => {
//.... some operation....
sender ! "someStringData"
}
case SomeClass(a, b, c) => {
//...some operations....
val result: Boolean = ..... // some operations....
sender ! new SomeReturnClass(result)
}
}
}
//.............................
object Application extends App {
val system = ActorSystem("HelloSystem")
val helloActor = system.actorOf(Props[Class1], name = "helloactor")
val stringData: String = helloActor ! someMethod1
val someClass: SomeReturnClass = helloActor ! someMethod2
}