sha*_*hai 1 websocket playframework-2.0
我正在使用Play framework 2.1.
我正在使用web-socket,我需要找到从服务器关闭它们的方法.
有没有办法做到这一点?
docs 处理WebSockets的示例:
让我们写另一个完全丢弃输入数据并在发送Hello之后关闭套接字的示例!信息:
public static WebSocket<String> index() {
return new WebSocket<String>() {
public void onReady(WebSocket.In<String> in, WebSocket.Out<String> out) {
out.write("Hello!");
out.close()
}
}
}
Run Code Online (Sandbox Code Playgroud)
def index = WebSocket.using[String] { request =>
// Just consume and ignore the input
val in = Iteratee.consume[String]()
// Send a single 'Hello!' message and close
val out = Enumerator("Hello!") >>> Enumerator.eof
(in, out)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
645 次 |
| 最近记录: |