nutzmore
nutzmore copied to clipboard
websocket 给指定会话发消息
将sessionid存到httpsession的时候不适用固定key,使用httpsessionid作为key不就好了嘛,反正httpsessionid在销毁前是有效的,所以在这个会话内给客户端发消息就很方便了
public void init() {
super.init();
if (httpSession != null)
httpSession.setAttribute(httpSession.getId() , session.getId());
}
websocketEndpoint.sendJson(httpsession.getAttribute(httpsession.getId()), msg);
考虑一下一个httpsession对应多个websocket的情况?
原来我一直没提交成功...