我正在使用Jooby的MVC路由。我还设置了一个websocket,一些客户端连接到它。我要做的是,每当服务器收到特定的http请求时,就向所有连接的websocket客户端发送一条消息。我的路由方法如下所示:
@Path("/player")
@Produces("application/json")
public class PlayerRoute {
@POST
public Result newPlayer(Request req, @Body Player player) {
//do some process here
//this is what I'm trying to achieve..
allWebsocketSessions.foreach(session ->
session.send("a new player has been created")
);
return Results.ok();
}
}我读过jooby的文档,但不知道怎么做。
提前谢谢。
发布于 2017-02-20 23:19:04
似乎对于"session“,你只能调用"set”和"get“方法。"send”方法你可以调用"response“。
https://stackoverflow.com/questions/42206161
复制相似问题