【发布时间】:2013-07-25 07:37:18
【问题描述】:
我尝试从 akk doc 实现 Actor DSL 示例,但发现错误,
不明确的隐含值:在 trait Inbox 类型的两个方法 senderFromInbox(隐含收件箱: akka.actor.ActorDSL.Inbox)akka.actor.ActorRef 并在类型的 trait Actor 中为 self 赋值 => akka.actor.ActorRef 匹配预期类型 akka.actor.ActorRef
下面是我的代码,
import akka.actor.ActorDSL._
import akka.actor.ActorSystem
import scala.concurrent.duration._
implicit val system: ActorSystem = ActorSystem("demo")
implicit val i = inbox()
val a = actor(new Act {
become {
case "hello" ⇒ sender ! "hi"
}
})
a ! "hello"
val reply = i.receive()
这里我不能使用“!”要发送消息,只能使用 sender.tell("hi", null) 之类的“tell”,有人知道如何解决这个问题吗?
【问题讨论】: