解决打包失败问题,去掉print

This commit is contained in:
2026-01-22 14:20:00 +08:00
parent cfe96ac2c7
commit 2101d76b08
3 changed files with 14 additions and 6 deletions

View File

@@ -1,14 +1,18 @@
package com.ttstd.signaling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WebRtcSignalingApplication {
static Logger logger = LoggerFactory.getLogger(WebRtcSignalingApplication.class);
public static void main(String[] args) {
SpringApplication.run(WebRtcSignalingApplication.class, args);
System.out.println("✅ WebRTC信令服务器启动成功WebSocket连接地址ws://localhost:2310/ws/rtc?userId=xxx");
logger.info("✅ WebRTC信令服务器启动成功WebSocket连接地址ws://localhost:2310/ws/rtc?userId=xxx");
}
}

View File

@@ -2,6 +2,8 @@ package com.ttstd.signaling.handler;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ttstd.signaling.entity.RtcSignalMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
@@ -19,6 +21,8 @@ import java.util.concurrent.ConcurrentHashMap;
@Component
public class WebRtcSignalHandler extends TextWebSocketHandler {
Logger logger = LoggerFactory.getLogger(WebRtcSignalHandler.class);
/**
* 核心维护在线用户的WebSocket会话映射
* key: 用户IDuserId
@@ -41,7 +45,7 @@ public class WebRtcSignalHandler extends TextWebSocketHandler {
if (userId != null && !userId.isEmpty()) {
// 将用户会话存入在线列表
ONLINE_USER_SESSIONS.put(userId, session);
System.out.println("用户[" + userId + "] 上线,当前在线人数:" + ONLINE_USER_SESSIONS.size());
logger.info("用户[" + userId + "] 上线,当前在线人数:" + ONLINE_USER_SESSIONS.size());
}
}
@@ -67,7 +71,7 @@ public class WebRtcSignalHandler extends TextWebSocketHandler {
if (targetSession != null && targetSession.isOpen()) {
// 将信令消息原样转发给目标用户
targetSession.sendMessage(new TextMessage(objectMapper.writeValueAsString(signalMessage)));
System.out.println("信令中转成功:[" + fromUserId + "] -> [" + toUserId + "] 类型:" + signalType);
logger.info("信令中转成功:[" + fromUserId + "] -> [" + toUserId + "] 类型:" + signalType);
} else {
// 目标用户不在线/连接已关闭
sendErrorMessage(session, "目标用户[" + toUserId + "] 不在线或连接已断开");
@@ -82,7 +86,7 @@ public class WebRtcSignalHandler extends TextWebSocketHandler {
String userId = getUserIdFromSession(session);
if (userId != null) {
ONLINE_USER_SESSIONS.remove(userId);
System.out.println("用户[" + userId + "] 下线,当前在线人数:" + ONLINE_USER_SESSIONS.size());
logger.info("用户[" + userId + "] 下线,当前在线人数:" + ONLINE_USER_SESSIONS.size());
}
}
@@ -94,7 +98,7 @@ public class WebRtcSignalHandler extends TextWebSocketHandler {
String userId = getUserIdFromSession(session);
if (userId != null) {
ONLINE_USER_SESSIONS.remove(userId);
System.out.println("用户[" + userId + "] 连接异常,已移除会话,异常信息:" + exception.getMessage());
logger.error("用户[" + userId + "] 连接异常,已移除会话,异常信息:" + exception.getMessage());
}
}

View File

@@ -1,2 +1,2 @@
spring.application.name=WebRTCSignaling
server.port=2310
server.port=5156