质安管理
This commit is contained in:
@ -59,18 +59,16 @@ public class BigScreenWebSocketServer {
|
||||
public void onOpen(Session session) {
|
||||
// 从连接URL的查询参数中获取订阅ID(客户端连接格式:ws://xxx/websocket/bigScreen?subscriptionId=123)
|
||||
Map<String, List<String>> params = session.getRequestParameterMap();
|
||||
Long timeType;
|
||||
|
||||
List<String> subscriptionIds = params.get("subscriptionId");
|
||||
if (subscriptionIds != null && !subscriptionIds.isEmpty()) {
|
||||
this.currentSubscriptionId = subscriptionIds.get(0); // 取第一个订阅ID
|
||||
timeType = Long.parseLong(params.get("timeType").getFirst());
|
||||
// 建立映射关系
|
||||
SUBSCRIPTION_SESSIONS.put(currentSubscriptionId, session);
|
||||
SESSION_TO_SUBSCRIPTION.put(session.getId(), currentSubscriptionId);
|
||||
log.info("📌 客户端订阅成功!订阅ID:{},会话ID:{},当前订阅数:{}",
|
||||
currentSubscriptionId, session.getId(), SUBSCRIPTION_SESSIONS.size());
|
||||
} else {
|
||||
timeType = null;
|
||||
log.warn("📌 客户端连接未携带订阅ID!会话ID:{}", session.getId());
|
||||
}
|
||||
|
||||
@ -98,6 +96,8 @@ public class BigScreenWebSocketServer {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
Long timeType;
|
||||
timeType = Long.parseLong(params.get("timeType").getFirst());
|
||||
//判断参数
|
||||
if (timeType == null || (timeType != 1L && timeType != 2L && timeType != 3L)){
|
||||
throw new RuntimeException("时间类型参数错误");
|
||||
|
||||
Reference in New Issue
Block a user