Browse Source

增加登录测试数据

johnclot69 1 month ago
parent
commit
46e8bb73be

+ 1 - 1
build.gradle

@@ -23,7 +23,7 @@ subprojects {
 
         // 启用现代编译参数
         options.compilerArgs.addAll([
-                '--enable-preview',          // 启用预览特性
+//                '--enable-preview',          // 启用预览特性
                 '-parameters'                // 保留方法参数名
         ])
     }

+ 1 - 1
incubator-core/src/main/java/com/incubator/core/network/WebSocketHandshakeHandler.java

@@ -13,7 +13,7 @@ import com.incubator.core.protocol.MsgPackCodec;
  */
 public class WebSocketHandshakeHandler extends SimpleChannelInboundHandler<Object> {
 
-    private World world;
+    private final World world;
 
     public WebSocketHandshakeHandler(World world) {
         this.world = world;

+ 12 - 1
incubator-core/src/main/java/com/incubator/core/protocol/Message.java

@@ -19,7 +19,18 @@ public class Message implements Serializable {
     public String message = "";
     public Map<String, Object> data = new ConcurrentHashMap<>();
 
-    public Message() { }
+    public Message() {}
+
+    public Message(int cmd, int code, String message) {
+        this.cmd = cmd;
+        this.code = code;
+        this.message = message;
+    }
+
+    public Message(int cmd, Map<String, Object> data) {
+        this.cmd = cmd;
+        this.data = data;
+    }
 
     public Message(int cmd, int code, String message, Map<String, Object> data) {
         this.cmd = cmd;

+ 45 - 2
incubator-game/src/main/java/com/incubator/game/handler/LoginHandler.java

@@ -1,9 +1,12 @@
 package com.incubator.game.handler;
 
+import com.incubator.core.Cmd;
 import com.incubator.core.message.MessageHandler;
 import com.incubator.core.protocol.Message;
 import io.netty.channel.Channel;
 
+import java.util.*;
+
 /**
  * 登录请求
  */
@@ -16,8 +19,48 @@ public class LoginHandler extends MessageHandler {
     @Override
     public void handle(Channel session, Message message) {
         String username = message.getDataValue("username", String.class, "");
-        String password = message.getDataValue("password", String.class, "");
 
-        session.writeAndFlush(new Message());
+        Map<String, Object> playerInfo = new HashMap<>();
+        playerInfo.put("id", UUID.randomUUID().toString());
+        playerInfo.put("name", username);
+        playerInfo.put("avatar", "https://img95.699pic.com/element/40112/2503.png_300.png");
+        playerInfo.put("sex", 0);
+        playerInfo.put("exp", 0L);
+        playerInfo.put("maxExp", 0);
+        playerInfo.put("vipLevel", 0);
+        playerInfo.put("masterScore", 0L);
+        playerInfo.put("masterScoreLevel", 0);
+        playerInfo.put("gold", 10000L);
+        playerInfo.put("diamond", 20000L);
+        playerInfo.put("startTimeVip", "");
+        playerInfo.put("endTimeVip", "");
+        playerInfo.put("gps", "");
+        playerInfo.put("gpsAddr", "");
+        playerInfo.put("foca", 0L);
+        playerInfo.put("ranking", 0);
+        playerInfo.put("figureId", 0);
+        playerInfo.put("realName", "李晓强");
+        playerInfo.put("phoneNum", "13800000001");
+        playerInfo.put("idCard", "42100119000101000X");
+        playerInfo.put("friendMasterNum", 0);
+        playerInfo.put("friendMasterRate", 0);
+        playerInfo.put("tradPoints", 0);
+        playerInfo.put("tradPointsRate", 0);
+        playerInfo.put("tradMatchNum", 0);
+        playerInfo.put("tradMatchRate", 0);
+        playerInfo.put("noReshNum", 0);
+        playerInfo.put("noReshRate", 0);
+
+        Map<String, Object> data = new HashMap<>();
+        data.put("playerInfo", playerInfo);
+        // 玩家绑定的房间号
+        data.put("roomId", 0L);
+        // 玩家绑定的官方比赛id
+        data.put("contestId", 0L);
+        // 官方比赛信息列表
+        data.put("contestInfo", new ArrayList<>());
+        data.put("eventList", "");
+
+        session.writeAndFlush(new Message(Cmd.LoginRes, data));
     }
 }