Skip to content

Commit a73a5d7

Browse files
committed
增加websocket
1 parent c1cd8c5 commit a73a5d7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

springboot-websocket/src/main/java/com/dev/websocket/config/SendMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void onOpen(Session session, @PathParam("userId") String userId) {
5151
} catch (IOException e) {
5252
e.printStackTrace();
5353
}
54-
log.info("有新连接加入:{},当前在线人数为:{}", session.getId(), onlineCount.get());
54+
log.info("用户:{}加入连接,当前在线人数为:{}", userId, onlineCount.get());
5555
}
5656

5757
/**
@@ -86,7 +86,7 @@ public void onMessage(String message, Session session) throws IOException {
8686
}
8787
}
8888

89-
log.info("服务端收到客户端[{}]的消息:{}", session.getId(), message);
89+
log.info("服务端收到客户端[{}]的消息:{}", userId, message);
9090
}
9191

9292
@OnError

springboot-websocket/src/main/java/com/dev/websocket/config/SendObjectMessage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void onOpen(Session session) {
3939
} catch (IOException e) {
4040
e.printStackTrace();
4141
}
42-
log.info("有新连接加入:{},当前在线人数为:{}", session.getId(), onlineCount.get());
42+
log.info("有新连接加入,当前在线人数为:{}", onlineCount.get());
4343
}
4444

4545
/**
@@ -50,7 +50,7 @@ public void onClose(Session session) {
5050
socket.remove(this);
5151
// 在线数减1
5252
onlineCount.decrementAndGet();
53-
log.info("用户退出,当前在线人数为:{}", session.getId(), onlineCount.get());
53+
log.info("用户退出,当前在线人数为:{}", onlineCount.get());
5454
}
5555

5656
/**
@@ -66,7 +66,7 @@ public void onMessage(String message, Session session) throws IOException {
6666
sendObjectMessage.sendMessage(message);
6767
}
6868
}
69-
log.info("服务端收到客户端[{}]的消息:{}", session.getId(), message);
69+
log.info("服务端收到客户端的消息:{}", message);
7070
}
7171

7272
@OnError

0 commit comments

Comments
 (0)