Sfoglia il codice sorgente

fix : Websocket调试修改00555

bilingfeng 1 anno fa
parent
commit
5e4a8f226c

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <Websocket调试修改003> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <Websocket调试修改00555> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 8 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IKfRoomService.java

@@ -40,6 +40,14 @@ public interface IKfRoomService extends IService<KfRoom> {
      */
     List<KfWebSocketMsgDTO.GameBean> getKfGameList();
 
+    /**
+     * 根据游戏获取游戏信息
+     *
+     * @param gameId : 游戏id
+     * @return : 返回游戏信息
+     */
+    List<KfWebSocketMsgDTO.GameBean> getKfGameByGameId(Long gameId);
+
     /**
      * 待接入房间列表
      *

+ 4 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/KfAppletMsgServiceImpl.java

@@ -103,6 +103,8 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
                 .gameId(gameId)
                 .roomId(kfRoom == null ? null : kfRoom.getId())
                 .build();
+        //游戏列表
+        kfWebSocketMsgDTO.setGameList(kfRoomService.getKfGameByGameId(gameId));
         //待接入消息
         if (Objects.equals(kfWebSocketMsgEnum, KfWebSocketMsgEnum.WEBSOCKET_MSG_WAIT_LIST)) {
             List<KfWebSocketMsgDTO.WaitUserBean> waitUserList = kfSessionUserService.getWaitUserList(gameId);
@@ -114,9 +116,9 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
             KfWebSocketMsgDTO.RoomMsgBean roomMsgBean = BeanUtil.copy(kfRoomMsg, KfWebSocketMsgDTO.RoomMsgBean.class);
             roomMsgBean.setContent(msgContent);
             kfWebSocketMsgDTO.setRoomMsgList(Collections.singletonList(roomMsgBean));
+            //房间, 空指针警告只是逻辑警告, kfRoom为空不会走到这里, 走上面的 if 条件
+            kfWebSocketMsgDTO.setRoomList(kfRoomService.getRoomByRoomId(kfRoom.getId()));
         }
-        //游戏列表
-        kfWebSocketMsgDTO.setGameList(kfRoomService.getKfGameList());
         return kfWebSocketMsgDTO;
     }
 

+ 10 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/KfRoomServiceImpl.java

@@ -120,6 +120,16 @@ public class KfRoomServiceImpl extends ServiceImpl<KfRoomMapper, KfRoom> impleme
         ).stream().map(this::transform).collect(Collectors.toList());
     }
 
+    @Override
+    public List<KfWebSocketMsgDTO.GameBean> getKfGameByGameId(Long gameId) {
+        GameApplet gameApplet = gameAppletService.getOne(new LambdaQueryWrapper<GameApplet>()
+                .eq(GameApplet::getGameId, gameId));
+        if (gameApplet == null) {
+            return Collections.emptyList();
+        }
+        return Collections.singletonList(this.transform(gameApplet));
+    }
+
     private KfWebSocketMsgDTO.GameBean transform(GameApplet gameApplet) {
         if (gameApplet == null) {
             return null;