|
@@ -1,81 +0,0 @@
|
|
-package com.sikey.wa04.business.application.usecase;
|
|
|
|
-
|
|
|
|
-import cn.hutool.core.util.CharsetUtil;
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
-import cn.hutool.http.HttpUtil;
|
|
|
|
-import com.sikey.wa04.business.domain.entity.Session;
|
|
|
|
-import com.sikey.wa04.common.exception.BusinessException;
|
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
-
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
-import java.util.Optional;
|
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
-import java.util.concurrent.ConcurrentMap;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 连接 Usecase
|
|
|
|
- *
|
|
|
|
- * @author luoyangwei
|
|
|
|
- */
|
|
|
|
-@Slf4j
|
|
|
|
-@Component
|
|
|
|
-public class WebSocketConnectionUsecase {
|
|
|
|
-// private static final ConcurrentMap<String, Session> SESSIONS = new ConcurrentHashMap<>();
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 默认语言
|
|
|
|
-// */
|
|
|
|
-// private static final String DEFAULT_LANGUAGE = "zh";
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 创建会话
|
|
|
|
-// *
|
|
|
|
-// * @param webSocketSession WebSocketSession
|
|
|
|
-// * @return Session
|
|
|
|
-// */
|
|
|
|
-// private Session createSession(WebSocketSession webSocketSession) {
|
|
|
|
-// Objects.requireNonNull(webSocketSession.getUri());
|
|
|
|
-// Map<String, String> request = HttpUtil.decodeParamMap(webSocketSession.getUri().getQuery(), CharsetUtil.CHARSET_UTF_8);
|
|
|
|
-//
|
|
|
|
-// String id = request.get("id");
|
|
|
|
-// String lang = request.get("lang");
|
|
|
|
-//
|
|
|
|
-// if (StrUtil.isBlank(id)) {
|
|
|
|
-// throw new BusinessException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "ID_REQUIRED", "id is required");
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if (StrUtil.isBlank(lang)) {
|
|
|
|
-// lang = DEFAULT_LANGUAGE;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// return Optional.
|
|
|
|
-// ofNullable(SESSIONS.get(id)).
|
|
|
|
-// orElse(new Session(id, lang, webSocketSession, LocalDateTime.now()));
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 连接建立
|
|
|
|
-// *
|
|
|
|
-// * @param webSocketSession WebSocketSession
|
|
|
|
-// * @return Session
|
|
|
|
-// * @throws Exception Exception
|
|
|
|
-// */
|
|
|
|
-// public Session established(WebSocketSession webSocketSession) throws Exception {
|
|
|
|
-// Session session = createSession(webSocketSession);
|
|
|
|
-// SESSIONS.put(session.getId(), session);
|
|
|
|
-// return session;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 连接建立
|
|
|
|
-// *
|
|
|
|
-// * @param webSocketSession WebSocketSession
|
|
|
|
-// * @throws Exception Exception
|
|
|
|
-// */
|
|
|
|
-// public void closed(WebSocketSession webSocketSession, CloseStatus closeStatus) throws Exception {
|
|
|
|
-// }
|
|
|
|
-}
|
|
|