| 类 | 说明 |
|---|---|
| GetHttpSessionConfigurator |
在@ServerEndpoint注解里面添加configurator属性[@ServerEndpoint(value="/socketTest",configurator=GetHttpSessionConfigurator.class)]
可以在OnOpen中通过HttpSession.class.getName()获取到http session,
那么我们就可以使用session.getId()来作为标识
@OnOpen
public void onOpen(Session session,EndpointConfig config) {
HttpSession httpSession= (HttpSession) config.getUserProperties().get(HttpSession.class.getName());
sessionMap.put(session.getId(), session);
}
{@link https://blog.csdn.net/huangbaokang/article/details/77579151?
|
| WebSocketHeartBeatChecker | |
| WebSocketSchedulingConfig |
只需要配置一下三个选项即可开启心跳监测
webSocket.heartCheck.enabled=true
webSocket.heartCheck.timeSpan=1000
webSocket.heartCheck.errorToleration=30
|