|
|
@ -12,11 +12,16 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.constants.RedisKeyConstants; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
|
|
|
import lombok.NoArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.web.socket.CloseStatus; |
|
|
|
import org.springframework.web.socket.CloseStatus; |
|
|
|
import org.springframework.web.socket.TextMessage; |
|
|
|
import org.springframework.web.socket.TextMessage; |
|
|
|
import org.springframework.web.socket.WebSocketSession; |
|
|
|
import org.springframework.web.socket.WebSocketSession; |
|
|
@ -33,7 +38,12 @@ import java.util.function.Function; |
|
|
|
* @Date: 2024/04/28 13:45 |
|
|
|
* @Date: 2024/04/28 13:45 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
|
|
|
|
@Component |
|
|
|
public class InteractiveHandler extends TextWebSocketHandler { |
|
|
|
public class InteractiveHandler extends TextWebSocketHandler { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void afterConnectionEstablished(WebSocketSession session) { |
|
|
|
public void afterConnectionEstablished(WebSocketSession session) { |
|
|
|
String[] split = session.getUri().toString().split("/"); |
|
|
|
String[] split = session.getUri().toString().split("/"); |
|
|
@ -67,9 +77,8 @@ public class InteractiveHandler extends TextWebSocketHandler { |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); |
|
|
|
String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey(); |
|
|
|
if(Func.isNotEmpty(messageJSON.containsKey("content"))) { |
|
|
|
if(messageJSON.containsKey("content")) { |
|
|
|
// 将发送参数存入redis
|
|
|
|
// 将发送参数存入redis
|
|
|
|
RedisTemplate redisTemplate = SpringUtil.getBean(RedisTemplate.class); |
|
|
|
|
|
|
|
redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); |
|
|
|
redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES); |
|
|
|
redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); |
|
|
|
redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class)); |
|
|
|
} |
|
|
|
} |
|
|
|