长连接 关闭日志打印
This commit is contained in:
@@ -38,12 +38,23 @@ public class NotificationConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnClose
|
@OnClose
|
||||||
public void onClose() {
|
public void onClose(CloseReason reason) {
|
||||||
websockets.remove(this); // 将当前的对象从集合中删除
|
websockets.remove(this); // 将当前的对象从集合中删除
|
||||||
log.info("【连接断开】 用户为:{}", this.session);
|
log.info("【连接断开】 用户为:{}, 原因为{}", this.session, reason);
|
||||||
// log.info("【连接断开】 总数为:{}", websockets.size());
|
// log.info("【连接断开】 总数为:{}", websockets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误时调用
|
||||||
|
* @param session 连接
|
||||||
|
* @param throwable 异常
|
||||||
|
*/
|
||||||
|
@OnError
|
||||||
|
public void onError(Session session, Throwable throwable) {
|
||||||
|
log.info("【连接异常】[session({}) 发生异常]", session, throwable);
|
||||||
|
websockets.remove(this); // 将当前的对象从集合中删除
|
||||||
|
}
|
||||||
|
|
||||||
//收到了客户端消息执行的操作
|
//收到了客户端消息执行的操作
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(String text){
|
public void onMessage(String text){
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration of WebSocket
|
* Configuration of WebSocket
|
||||||
*
|
|
||||||
* @author db1995
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebSocketConfig {
|
public class WebSocketConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user