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