我正在尝试在- 30 minutes to make realtime paint - youtube视频中的应用程序。我试着尽可能地紧跟它,在这之后,就像我认为它已经完成时一样,我收到了弃用警告!
我正在尝试学习scala & play。在没有帮助的情况下尝试了一下Googling;我只是不知道从哪里开始查找才能解决这个问题。
相关的代码片段出现在视频中的分钟:26左右。这里也有一个副本:
val hubEnum = Enumerator.imperative[JsValue]()
val hub = Concurrent.hub[JsValue](hubEnum)
var counter = 0
def index = Action {
Ok(views.html.index("Your new application is ready."))
}
def stream = WebSocket.async[JsValue] { request =>
var out = hub.getPatchCord()
counter += 1
var pid = counter
var in = Iteratee.foreach[JsValue](_ match {
case message: JsObject => {
hubEnum push(message ++ JsObject(Seq("pid" -> JsNumber(pid))))
}
})
Promise.pure((in, out))
}错误:
[warn] /home/user/devpt/testpaint/app/controllers/Application.scala:12: class PushEnumerator in package iteratee is deprecated: use Concurrent.broadcast instead
[warn] val hubEnum = Enumerator.imperative[JsValue]()
[warn] ^
[warn] /home/user/devpt/testpaint/app/controllers/Application.scala:12: method imperative in object Enumerator is deprecated: use Concurrent.broadcast instead
[warn] val hubEnum = Enumerator.imperative[JsValue]()
[warn] ^
[warn] /home/user/devpt/testpaint/app/controllers/Application.scala:13: trait Hub in object Concurrent is deprecated: use Concurrent.broadcast instead
[warn] val hub = Concurrent.hub[JsValue](hubEnum)
[warn] ^
[warn] /home/user/devpt/testpaint/app/controllers/Application.scala:13: method hub in object Concurrent is deprecated: use Concurrent.broadcast instead
[warn] val hub = Concurrent.hub[JsValue](hubEnum)
[warn] ^发布于 2013-06-12 23:57:01
Concurrent.broadcast是管理广播的新方法。它返回一个枚举数和一个Tuple2内部的通道。
在通道中,您可以通过push方法发送消息。
枚举器是客户端获取发送到通道的消息的方式,您可以通过Iteratee对其进行处理。
新的Websocket-Chat sample app展示了它的用法,下载它,你就可以用新的播放消息的方式替换相关的代码。
https://stackoverflow.com/questions/17068744
复制相似问题