Commit 1c41f8b1 by 钱炳权

exception is chaged

parent 3976f673
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.websocket.*; import javax.websocket.*;
...@@ -14,6 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -14,6 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
@Component("WebSocket") @Component("WebSocket")
@ServerEndpoint("/websocket/testResult/{name}") @ServerEndpoint("/websocket/testResult/{name}")
@Slf4j
public class WebSocket { public class WebSocket {
private Session session; //与某个客户端连接对话,通过此对客户端发送消息 private Session session; //与某个客户端连接对话,通过此对客户端发送消息
...@@ -24,7 +26,7 @@ public class WebSocket { ...@@ -24,7 +26,7 @@ public class WebSocket {
public void onOpen(Session session, @PathParam(value = "name") String name) { public void onOpen(Session session, @PathParam(value = "name") String name) {
this.session = session; //默认客户端,没有重名 this.session = session; //默认客户端,没有重名
WEBSOCKET_CONCURRENTHASHMAP.put(name, this); WEBSOCKET_CONCURRENTHASHMAP.put(name, this);
System.out.println("【webSocket连接成功】当前连接人数为:" + WEBSOCKET_CONCURRENTHASHMAP.size() + ",此人为:" + name); log.info("Websocket is connected! The man is {}.There are {} people in the connection ",name,WEBSOCKET_CONCURRENTHASHMAP.size());
} }
...@@ -40,8 +42,7 @@ public class WebSocket { ...@@ -40,8 +42,7 @@ public class WebSocket {
} }
} }
log.info("Websocket is closed! There are {} people in the connection ",WEBSOCKET_CONCURRENTHASHMAP.size());
System.out.println("【webSocket退出成功】当前连接人数为:" + WEBSOCKET_CONCURRENTHASHMAP.size());
} }
@OnError @OnError
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment