From 8546b3d285af4235a0ef615a0c6e89486ae2c806 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期四, 17 十月 2024 21:01:37 +0800 Subject: [PATCH] 达梦不支持value改为values --- src/main/java/com/ycl/jxkg/server/WebsocketServer.java | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ycl/jxkg/server/WebsocketServer.java b/src/main/java/com/ycl/jxkg/server/WebsocketServer.java index 2c3a644..a5f35a7 100644 --- a/src/main/java/com/ycl/jxkg/server/WebsocketServer.java +++ b/src/main/java/com/ycl/jxkg/server/WebsocketServer.java @@ -1,16 +1,15 @@ package com.ycl.jxkg.server; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.google.gson.JsonObject; -import com.ycl.jxkg.domain.entity.Message; import com.ycl.jxkg.domain.query.WebSocketQuery; +import com.ycl.jxkg.domain.vo.WebsocketDataVO; import com.ycl.jxkg.enums.WebsocketCommendEnum; import com.ycl.jxkg.service.EducationResourceService; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpSession; import javax.websocket.OnClose; import javax.websocket.OnMessage; import javax.websocket.OnOpen; @@ -32,8 +31,12 @@ @ServerEndpoint("/websocket/{userId}") public class WebsocketServer { - @Autowired - private EducationResourceService educationResourceService; + private static ApplicationContext applicationContext; + + public static void setApplicationContext(ApplicationContext context) { + applicationContext = context; + } + /** * 绾跨▼瀹夊叏鐨勬棤搴忕殑闆嗗悎 */ @@ -68,11 +71,19 @@ @OnMessage public void onMessage(String message) { WebSocketQuery webSocketQuery = JSONObject.parseObject(message, WebSocketQuery.class); - String commend = webSocketQuery.getCommend(); + String command = webSocketQuery.getCommand(); Integer userId = webSocketQuery.getId(); - if(WebsocketCommendEnum.RECORD_STUDY_TIME.getCommend().equals(commend)){ + if(WebsocketCommendEnum.RECORD_STUDY_TIME.getCommand().equals(command)){ + log.info("瀛樻秷鎭�"); + EducationResourceService educationResourceService = applicationContext.getBean(EducationResourceService.class); educationResourceService.recordTime(userId); } + // 浼氳鎿嶄綔 + if (WebsocketCommendEnum.MUTE.getCommand().equals(command) || WebsocketCommendEnum.OPEN_CAMERA.getCommand().equals(command) || WebsocketCommendEnum.KICK_OUT.getCommand().equals(command)) { + WebsocketDataVO websocketDataVO = new WebsocketDataVO(); + websocketDataVO.setCommend(command); + sendOneMessage(userId, JSON.toJSONString(websocketDataVO)); + } log.info("銆怶ebSocket娑堟伅銆戞敹鍒板鎴风娑堟伅锛�" + message); } -- Gitblit v1.8.0