我是 Finagle 的初学者。
今天我试图用finagle-websocket组合一个 hello world ,但我不明白为什么,当我运行它时,它不会阻止监听并死掉。测试WS.scala:
package foo.bar
import com.twitter.finagle.HttpWebSocket
import com.twitter.finagle.Service
import com.twitter.finagle.websocket.WebSocket
import com.twitter.util.Future
import com.twitter.concurrent.Broker
import com.twitter.util.RandomSocket
object TestWS {
def main(args: Array[String]) {
val server = HttpWebSocket.serve(RandomSocket(), new Service[WebSocket, WebSocket] {
def apply(req: WebSocket): Future[WebSocket] = {
val outgoing = new Broker[String]
val socket = req.copy(messages = outgoing.recv)
req.messages foreach { outgoing ! _.reverse }
Future.value(socket)
}
})
}
}
死前只输出这些行:
May 19, 2014 4:00:35 PM com.twitter.finagle.Init$ apply
INFO: Finagle version 6.14.0 (rev=3c3e9b0370f67cb739feca51469dc20eb35aab67) built at 20140417-
我究竟做错了什么?