我正在尝试使用Play Framework2.6来做以下事情:
1)可以通过路由轻松完成:
public WebSocket socket() {
return WebSocket.Text.accept(request -> {
// Log events to the console
Sink<String, ?> in = Sink.foreach(System.out::println);
// Send a single 'Hello!' message and then leave the socket open
Source<String, ?> out = Source.single("Hello!").concat(Source.maybe());
return Flow.fromSinkAndSource(in, out);
});
}
服务器端可以保存websocket。
2)但是如何通过websocket发送数据?(触发服务器端)
使用2.5很容易做到这一点,但是文档对play 2.6的帮助不是很大。
谢谢
https://stackoverflow.com/questions/53486314
复制相似问题