English 中文(简体)
游乐框架 2.0 - 死亡者而不是行为者
原标题:Play framework 2.0 - deadLetters instead of an Actor

学习目的 我试图实施简单的游戏应用,从遥远的行为者那里获得数据。 行为者守则如下:

import akka.actor.{Props, ActorSystem, Actor}

class NumbersServer extends Actor {
  var number = 0
  protected def receive = {
    case  next => {
      number += 1
      number
    }
    case  reset => number = 0
    case  exit => context.stop(self)
    case  get => sender ! number
  }
}

object Server {
  def main(args: Array[String]) {
    val system = ActorSystem("ServerSystem")
    val server = system.actorOf(Props[NumbersServer], "server")
  }
}

I package it into a jar and start it from the command line. If I try to send messages to this actor from a Scala console opened from another window, all works fine. Now I want to get the actor from the Play framework. In the Application object I define the following method:

def numbers = Action {
  Ok(views.html.numbers(Client.actor.path.name))
}

然后在<代码>中 一揽子方案一界定客户目标:

object Client {
  import play.api.Play.current
  val actor = Akka.system.actorFor("akka://[email protected]:2552/user/server")
}

The numbers.html.scala file:

@(message: String)

@main("Header") {
    <h1>@message</h1>
}

因此,我预计,当我去读127.0.0.1:9000/ numbers时,我就有了一条通往服务器行为体的道路。 相反,我拿到<代码><h1>deadLetters</h1>。 我做了哪些错误,如何正确做?

最佳回答

Please follow the configuration given in

https://groups.google.com/forum/#!topic/akka-user/Vw-B8nQeagk

此外,还增加了对卡-雷特的依赖

val appDependencies = Seq(
    "com.typesafe.akka" % "akka-remote" % "2.0.2"
)
问题回答

暂无回答




相关问题
How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...

To use or not to use Scala for new Java projects? [closed]

I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

Scala and tail recursion

There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...

热门标签