编写未来列表Akka Scala
我正试图从Akka actors收集未来自定义对象的列表,这是我的代码:编写未来列表Akka Scala,scala,akka,Scala,Akka,我正试图从Akka actors收集未来自定义对象的列表,这是我的代码: var game_manager_backends: List[ActorRef] = List() implicit val ec = context.dispatcher val taskFutures: List[Future[Game]] = game_manager_backends map { gm_be => implicit val timeout = Tim
var game_manager_backends: List[ActorRef] = List()
implicit val ec = context.dispatcher
val taskFutures: List[Future[Game]] = game_manager_backends map { gm_be =>
implicit val timeout = Timeout(5 seconds)
val result = gm_be ? GameStatus
}
val searchFuture = Future sequence taskFutures
searchFuture.onSuccess {
case results: List[Game] => origin ! results
}
这个
是一个列表,其中包含我想要询问的游戏
对象的所有参与者,然后我想要收集列表中的所有游戏
对象,并发送回原始参与者,使用此实现,这是映射
行上给出的错误:
type mismatch; found : List[Unit] required: List[scala.concurrent.Future[common.Game]]
我怎样才能解决这个问题
谢谢
单位
原因不返回映射
中的任何值(在注释中修复上述建议)?
ask on akka返回Future[Any]
,但您希望Future[common.Game]
修复此问题-需要额外的映射结果映射{
案例a@Game=>a
}
单位
原因不返回映射
中的任何值(在注释中修复上述建议)?
ask on akka返回Future[Any]
,但您希望Future[common.Game]
修复此问题-需要额外的映射结果映射{
案例a@Game=>a
}
更改val result=gm\u be?游戏状态
toval result=(gm_be?GameStatus)。映射到[游戏]
。您也不需要它是val
更改val result=gm\u be?游戏状态
toval result=(gm_be?GameStatus)。映射到[游戏]
。您也不需要它是val
删除val result=
或添加另一行result
stmt。如果我删除val result=
这是错误:类型不匹配;找到:List[scala.concurrent.Future[Any]]必需:List[scala.concurrent.Future[common.Game]
删除val result=
或添加另一行result
stmt。如果我删除val result=
这是错误:类型不匹配;找到:List[scala.concurrent.Future[Any]]必需:List[scala.concurrent.Future[common.Game]]
您能用您的解决方案编写上面的代码吗?因为我不明白你的意思,谢谢在@nattyddubbscan的另一个答案中看到我的评论。你能用你的解决方案写我的代码吗?因为我不明白你的意思,谢谢你在@nattyddubbs的另一个答案中看到我的评论如果我这样做(gm_be?GameStatus)。mapTo[Game]
没有val result=
我很高兴。希望能有帮助。如果我这样做(gm_be?GameStatus)。mapTo[Game]
没有val result=
工作,我很高兴。希望能有所帮助。
type mismatch; found : List[Unit] required: List[scala.concurrent.Future[common.Game]]