在JSP页面已经显示OnOpen成功了
2017-11-15 14:33:41,263 org.nutz.plugins.mvc.websocket.handler.AbstractWsHandler.join(AbstractWsHandler.java:50) DEBUG - session(id=ulv4um8gfuiknpopcif1gbh62m) join room(name=wsroom:home)
console.log也先是了websocket onopen ...
可是服务端如何给jsp页面发消息呢。。。怎么获取wsid?
我按照 https://github.com/nutzam/nutzmore/tree/master/nutz-plugins-websocket 这里配置的
@ServerEndpoint(value = "/websocket", configurator = NutWsConfigurator.class)
@IocBean
public class MyWebsocket extends AbstractWsEndpoint {
// public WsHandler createHandler(Session session, EndpointConfig config) {
// return new MySimpleWsHandler(); // 是的,返回你自己的实现类就可以了,需要每次新建哦
// }
}
我想在这里用
@IocBean
@At("/user")
@Ok("json:{locked:'password|salt',ignoreNull:true}")
@Fail("http:500")
public class UserModule {
@Inject
protected Dao dao;
@Inject
protected MyWebsocket myWebsocket;
@At
public Integer count(HttpSession httpSession) {
myWebsocket.sendJson(wsid,"Hello World!!");
System.out.println("接受接受~");
return this.dao.count(User.class);
}
服务端应该怎么写?