Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket 给指定会话发消息 #102

Open
Leewell1989 opened this issue May 19, 2018 · 1 comment
Open

websocket 给指定会话发消息 #102

Leewell1989 opened this issue May 19, 2018 · 1 comment

Comments

@Leewell1989
Copy link

Leewell1989 commented May 19, 2018

将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);
@wendal
Copy link
Member

wendal commented Jun 4, 2018

考虑一下一个httpsession对应多个websocket的情况?

原来我一直没提交成功...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants