From 0292e485f664575527bd612a561c252462ac7c61 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 26 Apr 2022 20:00:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20ca?= =?UTF-8?q?se=E6=89=A7=E8=A1=8C=E6=94=B6=E4=B8=8D=E5=88=B0=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1012793 --user=赵勇 【接口测试】接口定义-接口case中query参数值是json文件-执行多次卡住 https://www.tapd.cn/55049933/s/1148609 --- .../websocket/c/to/c/IndexWebSocket.java | 6 ++---- .../websocket/c/to/c/MsWebSocketClient.java | 14 ++++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/metersphere/websocket/c/to/c/IndexWebSocket.java b/backend/src/main/java/io/metersphere/websocket/c/to/c/IndexWebSocket.java index 143a9cb9b8..62593bbd11 100644 --- a/backend/src/main/java/io/metersphere/websocket/c/to/c/IndexWebSocket.java +++ b/backend/src/main/java/io/metersphere/websocket/c/to/c/IndexWebSocket.java @@ -21,8 +21,7 @@ public class IndexWebSocket { @OnOpen public void openSession(@PathParam("reportId") String reportId, Session session) { WebSocketUtils.ONLINE_USER_SESSIONS.put(reportId, session); - log.info("客户端: [" + reportId + "] : 连接成功!"); - //WebSocketUtils.sendMessageAll("客户端: [" + reportId + "] : 连接成功!"); + log.info("客户端: [" + reportId + "] : 连接成功!" + WebSocketUtils.ONLINE_USER_SESSIONS.size()); } /** @@ -43,9 +42,8 @@ public class IndexWebSocket { public void onClose(@PathParam("reportId") String reportId, Session session) throws IOException { //当前的Session 移除 WebSocketUtils.ONLINE_USER_SESSIONS.remove(reportId); - log.info("[" + reportId + "] : 断开连接!"); + log.info("[" + reportId + "] : 断开连接!" + WebSocketUtils.ONLINE_USER_SESSIONS.size()); //并且通知其他人当前用户已经断开连接了 - //WebSocketUtils.sendMessageAll("[" + reportId + "] : 断开连接!"); session.close(); } diff --git a/backend/src/main/java/io/metersphere/websocket/c/to/c/MsWebSocketClient.java b/backend/src/main/java/io/metersphere/websocket/c/to/c/MsWebSocketClient.java index b7f31a57d0..1c73159ad4 100644 --- a/backend/src/main/java/io/metersphere/websocket/c/to/c/MsWebSocketClient.java +++ b/backend/src/main/java/io/metersphere/websocket/c/to/c/MsWebSocketClient.java @@ -1,8 +1,6 @@ package io.metersphere.websocket.c.to.c; -import com.alibaba.fastjson.JSON; import io.metersphere.commons.utils.LogUtil; -import io.metersphere.websocket.c.to.c.util.MsgDto; import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; @@ -10,23 +8,23 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; -public class MsWebSocketClient extends WebSocketClient{ +public class MsWebSocketClient extends WebSocketClient { public MsWebSocketClient(String url) throws URISyntaxException { super(new URI(url)); } @Override public void onOpen(ServerHandshake shake) { - System.out.println("握手..."); - for(Iterator it=shake.iterateHttpFields();it.hasNext();) { + LogUtil.info("握手..."); + for (Iterator it = shake.iterateHttpFields(); it.hasNext(); ) { String key = it.next(); - System.out.println(key+":"+shake.getFieldValue(key)); + System.out.println(key + ":" + shake.getFieldValue(key)); } } @Override public void onMessage(String paramString) { - System.out.println("接收到消息:"+paramString); + System.out.println("接收到消息:" + paramString); } @Override @@ -36,6 +34,6 @@ public class MsWebSocketClient extends WebSocketClient{ @Override public void onError(Exception e) { - System.out.println("异常"+e); + System.out.println("异常" + e); } }