Merge branch 'master' of 60.1.1.230:backend/jieling_server

back_recharge
wangyuan 2019-01-07 10:01:07 +08:00
commit d30ec31a63
20 changed files with 11264 additions and 599 deletions

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.handler;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.MessageUtil;
@ -33,11 +34,16 @@ public class LoginRequestHandler extends BaseHandler {
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
CommonProto.Common.Player player = CommonProto.Common.Player
.newBuilder()
.setUid(12345)
.setGold(10000)
.build();
PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse getPlayerInfoResponse
= PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse.newBuilder()
.setRank(12)
.setSex(1)
.setFamily("hello world!")
.setPlayer(player)
.build();
try {
MessageUtil.sendMessage(iSession, userId,msgIndex, 1, msgId+1, getPlayerInfoResponse, true);

View File

@ -1,5 +1,51 @@
package com.ljsd.jieling.logic;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.network.session.ISession;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class OnlineUserManager {
public static Map<Integer, Integer> onlineUidMap = new ConcurrentHashMap<>();
public static Map<Integer, ISession> sessionMap = new ConcurrentHashMap<>();
public static Map<Integer, PlayerInfo> onlineUserMap = new ConcurrentHashMap<>(10000);
public static void registUser(int uid, int serverId, ISession session) {
onlineUidMap.put(uid, serverId);
sessionMap.put(uid, session);
}
public static void unRegistUser(int uid) {
onlineUidMap.remove(uid);
sessionMap.remove(uid);
}
/**
* uidSession
* @param uid
* @return
*/
public static ISession getSessionByUid(int uid) {
if(sessionMap == null){
return null;
}
return sessionMap.get(uid);
}
/**
* 线
* @param uid
* @return
*/
public static boolean checkUidOnline(int uid) {
if(sessionMap == null){
return false;
}
return sessionMap.containsKey(uid);
}
}

View File

@ -0,0 +1,5 @@
package com.ljsd.jieling.logic.dao;
public class HeroManager {
}

View File

@ -0,0 +1,6 @@
package com.ljsd.jieling.logic.dao;
public class ItemManager {
}

View File

@ -0,0 +1,4 @@
package com.ljsd.jieling.logic.dao;
public class MapManager {
}

View File

@ -0,0 +1,14 @@
package com.ljsd.jieling.logic.dao;
public class PlayerInfo {
private UserManager userManager;
private ItemManager itemManager;
private HeroManager heroManager;
private MapManager mapManager;
}

View File

@ -0,0 +1,4 @@
package com.ljsd.jieling.logic.dao;
public class UserManager {
}

View File

@ -1,34 +0,0 @@
package com.ljsd.jieling.logic.map;
public class CCell {
private int coordinateX;
private int coordinateY;
private int eventType;
public int getCoordinateX() {
return coordinateX;
}
public void setCoordinateX(int coordinateX) {
this.coordinateX = coordinateX;
}
public int getCoordinateY() {
return coordinateY;
}
public void setCoordinateY(int coordinateY) {
this.coordinateY = coordinateY;
}
public int getEventType() {
return eventType;
}
public void setEventType(int eventType) {
this.eventType = eventType;
}
}

View File

@ -4,6 +4,7 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -13,11 +14,17 @@ public class CMap {
@Id
private int id;
@Field(value = "curMapId")
private int curMapId;
@Field(value = "curXY")
private int curXY;
@Field(value = "mapInfo")
private Map<Integer, CCell> mapInfo = new ConcurrentHashMap<>();
private Map<Integer, Cell> mapInfo = new ConcurrentHashMap<>();
@Field(value = "crossMapInfos")
private Map<Integer, Integer> crossMapInfos = new ConcurrentHashMap<>();
private Map<Integer, List<Integer>> crossMapInfos = new ConcurrentHashMap<>();
public void setId(int id) {
@ -28,11 +35,27 @@ public class CMap {
return id;
}
public Map<Integer, CCell> getMapInfo() {
public Map<Integer, Cell> getMapInfo() {
return mapInfo;
}
public Map<Integer, Integer> getCrossMapInfos() {
public Map<Integer, List<Integer>> getCrossMapInfos() {
return crossMapInfos;
}
public int getCurMapId() {
return curMapId;
}
public void setCurMapId(int curMapId) {
this.curMapId = curMapId;
}
public int getCurXY() {
return curXY;
}
public void setCurXY(int curXY) {
this.curXY = curXY;
}
}

View File

@ -0,0 +1,24 @@
package com.ljsd.jieling.logic.map;
import com.google.common.collect.Sets;
import java.util.Set;
public class Cell {
private Set<Integer> eventIds = Sets.newConcurrentHashSet();;
private boolean isFinish;
public Set<Integer> getEventIds() {
return eventIds;
}
public boolean isFinish() {
return isFinish;
}
public void setFinish(boolean finish) {
isFinish = finish;
}
}

View File

@ -0,0 +1,14 @@
package com.ljsd.jieling.logic.map;
public class EventType {
// 事件点类型 1怪物 2怪物群 3矿 4入口 5出口 6一次性事件 7重复事件 8npc 9地图boss
public static final int monster = 1;
public static final int monsters = 2;
public static final int mine = 3;
public static final int enter = 4;
public static final int exit = 5;
public static final int disposable = 6;
public static final int repeated = 7;
public static final int npc = 8;
public static final int boss = 8;
}

View File

@ -1,10 +1,15 @@
package com.ljsd.jieling.logic.map;
import com.ljsd.jieling.models.SCMap;
import com.ljsd.jieling.models.SCMapEvent;
import com.ljsd.jieling.util.ToolsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class MapLogic {
@ -24,8 +29,22 @@ public class MapLogic {
public final static MapLogic instance = new MapLogic();
}
/**
*
* @param uid
*/
public void getMapInfo(int uid) {
// get db
CMap cMap = null;
if (cMap == null) {
initMap(uid, 1);
}
public void initMap(int uid, int mapId) {
// save db
}
private void initMap(int uid, int mapId) {
if (mapId == 0) {
mapId = 1;
}
@ -35,10 +54,59 @@ public class MapLogic {
}
CMap cMap = new CMap();
cMap.setId(uid);
cMap.setCurMapId(mapId);
Map<Integer, Cell> mapInfo = cMap.getMapInfo();
mapInfo.clear();
Random random = new Random();
for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
// cMap.getMapInfo().put()
SCMap scMap1 = entry.getValue();
Cell cellValue = new Cell();
cellValue.getEventIds().add(scMap1.getEvent());
int randomIndex = random.nextInt(scMap1.getGroups().length);
int x = scMap1.getGroups()[randomIndex][0];
int y = scMap1.getGroups()[randomIndex][1];
int xy = ToolsUtil.xy2Pos(x, y);
SCMapEvent scMapEvent = SCMapEvent.scMapEventMap.get(scMap1.getEvent());
if (scMapEvent.getStyle() == EventType.enter) {
cMap.setCurXY(xy);
}
mapInfo.put(xy, cellValue);
}
}
/**
*
* @param uid
* @param xy
*/
public void finishEvent(int uid, int xy) {
// get db
CMap cMap = null;
Cell cell = cMap.getMapInfo().get(xy);
if (cell == null) {
return;
}
if (cell.getEventIds().isEmpty()) {
return;
}
cMap.setCurXY(xy);
cell.setFinish(true);
SCMapEvent scMapEvent = SCMapEvent.scMapEventMap.get(cell.getEventIds());
// 如果是出口开启跳转到下个关卡
if (scMapEvent.getStyle() == EventType.disposable) {
Map<Integer, List<Integer>> crossMapInfos = cMap.getCrossMapInfos();
if (!crossMapInfos.containsKey(cMap.getCurMapId())) {
crossMapInfos.put(cMap.getCurMapId(), new ArrayList<>());
}
crossMapInfos.get(cMap.getCurMapId()).addAll(cell.getEventIds());
}
if (scMapEvent.getStyle() == EventType.exit) {
initMap(uid, cMap.getCurMapId() + 1);
return;
}
cell.setFinish(true);
// save db
}
}

View File

@ -0,0 +1,43 @@
package com.ljsd.jieling.models;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name = "s_c_map_event")
public class SCMapEvent implements BaseConfig{
public static Map<Integer, SCMapEvent> scMapEventMap;
private int id;
/**
* "
* 1 2 3 4 5 6 7 8npc 9boss "
*/
private int style;
/**
*
* 1
* 2
* 3
*/
private int refrsh;
@Override
public void init() throws Exception {
scMapEventMap = STableManager.getConfig(SCMapEvent.class);
}
public int getId() {
return id;
}
public int getStyle() {
return style;
}
public int getRefrsh() {
return refrsh;
}
}

View File

@ -46,8 +46,10 @@ public class NettyClient {
/*---------------------------------------------------------------------------------------------------------*/
while (true){
Thread.sleep(10000);
List<PacketNetData> result = handler.sendRequest_jieling(gameMessage);
Thread.sleep(5000);
// List<PacketNetData> result = handler.sendRequest_jieling(gameMessage);
List<PacketNetData> result = handler.sendHeartBeat_jieling();
LOGGER.info("send to server...");
}
// ch.close();
@ -64,9 +66,9 @@ public class NettyClient {
LOGGER.info("register");
PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest registerRequest = PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest
.newBuilder()
.setNum(888)
.setStr("666")
.setStr1("222")
// .setNum(888)
// .setStr("666")
// .setStr1("222")
.build();
return registerRequest;

View File

@ -84,6 +84,18 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
}
public List<PacketNetData> sendHeartBeat_jieling() {
byte[] finalMessage = makeHeartBeatMessage();
channel.writeAndFlush(finalMessage);
ArrayList<PacketNetData> msgs = new ArrayList<PacketNetData>();
return msgs;
}
private byte[] makeFinalMessage(MessageLite request) {
byte[] messageData = request.toByteArray();
byte[] packetData = new byte[messageData.length + 16];
@ -99,6 +111,17 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
return finalData;
}
private byte[] makeHeartBeatMessage() {
byte[] packetData = new byte[12];
Tea.intToByte(packetData, 0, 10000001);
Tea.intToByte(packetData, 4, 543242);
Tea.intToByte(packetData, 8, 1000);
int[] secretKey = Tea.KEY;
byte[] finalData = Tea.encrypt2(packetData, secretKey);
return finalData;
}
@Override
public void channelRegistered(ChannelHandlerContext ctx) {
@ -113,17 +136,20 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
int userId = packetNetData.getUserId();
int token = packetNetData.getToken();
int msgId = packetNetData.getMsgId();
int msgIndex = packetNetData.getIndex();
int resultCode = packetNetData.getResult();
byte[] backmessage = packetNetData.parseServerProtoNetData();
PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse getPlayerInfoResponse
= PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse.parseFrom(backmessage);
System.out.println("back hartbeat id : "+msgId);
LOGGER.info("serverBack processMessage->uid={},token={},msgId={},msgIndex={},resultCode={}" +
",backMessageRank={},backMessageFamily={},backMessageSex={}",
userId, token,msgId,msgIndex,resultCode,getPlayerInfoResponse.getRank(),
getPlayerInfoResponse.getFamily(),getPlayerInfoResponse.getSex());
// int msgIndex = packetNetData.getIndex();
// int resultCode = packetNetData.getResult();
// byte[] backmessage = packetNetData.parseServerProtoNetData();
// PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse getPlayerInfoResponse
// = PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse.parseFrom(backmessage);
// LOGGER.info("serverBack processMessage->uid={},token={},msgId={},msgIndex={},resultCode={}" +
// ",backMessageRank={},backMessageFamily={},backMessageSex={}",
// userId, token,msgId,msgIndex,resultCode,getPlayerInfoResponse.getRank(),
// getPlayerInfoResponse.getFamily(),getPlayerInfoResponse.getSex());
}

View File

@ -10,6 +10,7 @@ import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocol.ProtocolsAbstract;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.session.GameSession;
import com.ljsd.jieling.util.MessageUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufHolder;
import io.netty.channel.group.ChannelGroup;
@ -18,10 +19,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
@ -198,6 +196,29 @@ public class ProtocolsManager implements ProtocolsAbstract {
}
final ISession session = (ISession) gameSession;
PacketNetData packetNetData = new PacketNetData((byte[])obj);
if (packetNetData.getMsgId()==1000){
new Thread(new Runnable() {
@Override
public void run() {
Random random = new Random();
int time = random.nextInt(6)+1;
try {
System.out.println("sleep time : "+time);
Thread.sleep(time*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Thread.currentThread().setName("OOOOOOOOO");
MessageUtil.sendHeartBeat(session);
}
}).start();
return;
}
BaseHandler baseHandler = handlers.get(packetNetData.getMsgId());
if (baseHandler == null) {
LOGGER.info("request unknow commond : " + packetNetData.getMsgId());

View File

@ -41,6 +41,94 @@ public final class MessageTypeProto {
* <code>LOGIN_RESPONSE = 10001;</code>
*/
LOGIN_RESPONSE(3, 10001),
/**
* <code>GET_PLAYERINFO_REQUEST = 10002;</code>
*
* <pre>
* </pre>
*/
GET_PLAYERINFO_REQUEST(4, 10002),
/**
* <code>GET_PLAYERINFO_RESPONSE = 10003;</code>
*/
GET_PLAYERINFO_RESPONSE(5, 10003),
/**
* <code>GET_HEROINFO_REQUEST = 10004;</code>
*
* <pre>
* </pre>
*/
GET_HEROINFO_REQUEST(6, 10004),
/**
* <code>GET_HEROINFO_RESPONSE = 10005;</code>
*/
GET_HEROINFO_RESPONSE(7, 10005),
/**
* <code>GET_ITEMINFO_REQUEST = 10006;</code>
*
* <pre>
* </pre>
*/
GET_ITEMINFO_REQUEST(8, 10006),
/**
* <code>GET_ITEMINFO_RESPONSE = 10007;</code>
*/
GET_ITEMINFO_RESPONSE(9, 10007),
/**
* <code>ENTER_MAP_REQUEST = 10008;</code>
*
* <pre>
* </pre>
*/
ENTER_MAP_REQUEST(10, 10008),
/**
* <code>ENTER_MAP_RESPONSE = 10009;</code>
*/
ENTER_MAP_RESPONSE(11, 10009),
/**
* <code>START_FIGHT_REQUEST = 10010;</code>
*
* <pre>
* </pre>
*/
START_FIGHT_REQUEST(12, 10010),
/**
* <code>START_FIGHT_RESPONSE = 10011;</code>
*/
START_FIGHT_RESPONSE(13, 10011),
/**
* <code>END_FIGHT_REQUEST = 10012;</code>
*
* <pre>
* </pre>
*/
END_FIGHT_REQUEST(14, 10012),
/**
* <code>END_FIGHT_RESPONSE = 10013;</code>
*/
END_FIGHT_RESPONSE(15, 10013),
/**
* <code>TRIGGER_EVENT_REQUEST = 10014;</code>
*
* <pre>
* </pre>
*/
TRIGGER_EVENT_REQUEST(16, 10014),
/**
* <code>TRIGGER_EVENT_RESPONSE = 10015;</code>
*/
TRIGGER_EVENT_RESPONSE(17, 10015),
/**
* <code>OUT_MAP_REQUEST = 10016;</code>
*
* <pre>
* </pre>
*/
OUT_MAP_REQUEST(18, 10016),
/**
* <code>OUT_MAP_RESPONSE = 10017;</code>
*/
OUT_MAP_RESPONSE(19, 10017),
;
/**
@ -71,6 +159,94 @@ public final class MessageTypeProto {
* <code>LOGIN_RESPONSE = 10001;</code>
*/
public static final int LOGIN_RESPONSE_VALUE = 10001;
/**
* <code>GET_PLAYERINFO_REQUEST = 10002;</code>
*
* <pre>
* </pre>
*/
public static final int GET_PLAYERINFO_REQUEST_VALUE = 10002;
/**
* <code>GET_PLAYERINFO_RESPONSE = 10003;</code>
*/
public static final int GET_PLAYERINFO_RESPONSE_VALUE = 10003;
/**
* <code>GET_HEROINFO_REQUEST = 10004;</code>
*
* <pre>
* </pre>
*/
public static final int GET_HEROINFO_REQUEST_VALUE = 10004;
/**
* <code>GET_HEROINFO_RESPONSE = 10005;</code>
*/
public static final int GET_HEROINFO_RESPONSE_VALUE = 10005;
/**
* <code>GET_ITEMINFO_REQUEST = 10006;</code>
*
* <pre>
* </pre>
*/
public static final int GET_ITEMINFO_REQUEST_VALUE = 10006;
/**
* <code>GET_ITEMINFO_RESPONSE = 10007;</code>
*/
public static final int GET_ITEMINFO_RESPONSE_VALUE = 10007;
/**
* <code>ENTER_MAP_REQUEST = 10008;</code>
*
* <pre>
* </pre>
*/
public static final int ENTER_MAP_REQUEST_VALUE = 10008;
/**
* <code>ENTER_MAP_RESPONSE = 10009;</code>
*/
public static final int ENTER_MAP_RESPONSE_VALUE = 10009;
/**
* <code>START_FIGHT_REQUEST = 10010;</code>
*
* <pre>
* </pre>
*/
public static final int START_FIGHT_REQUEST_VALUE = 10010;
/**
* <code>START_FIGHT_RESPONSE = 10011;</code>
*/
public static final int START_FIGHT_RESPONSE_VALUE = 10011;
/**
* <code>END_FIGHT_REQUEST = 10012;</code>
*
* <pre>
* </pre>
*/
public static final int END_FIGHT_REQUEST_VALUE = 10012;
/**
* <code>END_FIGHT_RESPONSE = 10013;</code>
*/
public static final int END_FIGHT_RESPONSE_VALUE = 10013;
/**
* <code>TRIGGER_EVENT_REQUEST = 10014;</code>
*
* <pre>
* </pre>
*/
public static final int TRIGGER_EVENT_REQUEST_VALUE = 10014;
/**
* <code>TRIGGER_EVENT_RESPONSE = 10015;</code>
*/
public static final int TRIGGER_EVENT_RESPONSE_VALUE = 10015;
/**
* <code>OUT_MAP_REQUEST = 10016;</code>
*
* <pre>
* </pre>
*/
public static final int OUT_MAP_REQUEST_VALUE = 10016;
/**
* <code>OUT_MAP_RESPONSE = 10017;</code>
*/
public static final int OUT_MAP_RESPONSE_VALUE = 10017;
public final int getNumber() { return value; }
@ -81,6 +257,22 @@ public final class MessageTypeProto {
case 1001: return HEART_BEAT_RESPONSE;
case 10000: return LOGIN_REQUEST;
case 10001: return LOGIN_RESPONSE;
case 10002: return GET_PLAYERINFO_REQUEST;
case 10003: return GET_PLAYERINFO_RESPONSE;
case 10004: return GET_HEROINFO_REQUEST;
case 10005: return GET_HEROINFO_RESPONSE;
case 10006: return GET_ITEMINFO_REQUEST;
case 10007: return GET_ITEMINFO_RESPONSE;
case 10008: return ENTER_MAP_REQUEST;
case 10009: return ENTER_MAP_RESPONSE;
case 10010: return START_FIGHT_REQUEST;
case 10011: return START_FIGHT_RESPONSE;
case 10012: return END_FIGHT_REQUEST;
case 10013: return END_FIGHT_RESPONSE;
case 10014: return TRIGGER_EVENT_REQUEST;
case 10015: return TRIGGER_EVENT_RESPONSE;
case 10016: return OUT_MAP_REQUEST;
case 10017: return OUT_MAP_RESPONSE;
default: return null;
}
}
@ -142,10 +334,20 @@ public final class MessageTypeProto {
static {
java.lang.String[] descriptorData = {
"\n\026MessageTypeProto.proto\022\032com.ljsd.jieli" +
"ng.protocols*i\n\013MessageType\022\027\n\022HEART_BEA" +
"T_REQUEST\020\350\007\022\030\n\023HEART_BEAT_RESPONSE\020\351\007\022\022" +
"\n\rLOGIN_REQUEST\020\220N\022\023\n\016LOGIN_RESPONSE\020\221NB" +
"\002H\001"
"ng.protocols*\217\004\n\013MessageType\022\027\n\022HEART_BE" +
"AT_REQUEST\020\350\007\022\030\n\023HEART_BEAT_RESPONSE\020\351\007\022" +
"\022\n\rLOGIN_REQUEST\020\220N\022\023\n\016LOGIN_RESPONSE\020\221N" +
"\022\033\n\026GET_PLAYERINFO_REQUEST\020\222N\022\034\n\027GET_PLA" +
"YERINFO_RESPONSE\020\223N\022\031\n\024GET_HEROINFO_REQU" +
"EST\020\224N\022\032\n\025GET_HEROINFO_RESPONSE\020\225N\022\031\n\024GE" +
"T_ITEMINFO_REQUEST\020\226N\022\032\n\025GET_ITEMINFO_RE" +
"SPONSE\020\227N\022\026\n\021ENTER_MAP_REQUEST\020\230N\022\027\n\022ENT" +
"ER_MAP_RESPONSE\020\231N\022\030\n\023START_FIGHT_REQUES",
"T\020\232N\022\031\n\024START_FIGHT_RESPONSE\020\233N\022\026\n\021END_F" +
"IGHT_REQUEST\020\234N\022\027\n\022END_FIGHT_RESPONSE\020\235N" +
"\022\032\n\025TRIGGER_EVENT_REQUEST\020\236N\022\033\n\026TRIGGER_" +
"EVENT_RESPONSE\020\237N\022\024\n\017OUT_MAP_REQUEST\020\240N\022" +
"\025\n\020OUT_MAP_RESPONSE\020\241NB\002H\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {

View File

@ -53,6 +53,20 @@ public class MessageUtil {
}
}
public static void sendHeartBeat(ISession session) {
int length = PackageConstant.UID_FIELD_LEN + PackageConstant.TOKEN_LEN
+ PackageConstant.MSG_ID_FIELD_LEN ;
byte[] bytes = new byte[length];
int pos = 0;
Tea.intToByte(bytes, pos, 100001);
pos += PackageConstant.UID_FIELD_LEN;
Tea.intToByte(bytes, pos, 123456);
pos += PackageConstant.TOKEN_LEN;
Tea.intToByte(bytes, pos, 1001);
byte[] byteBuf = Tea.encrypt2(bytes, Tea.KEY);
session.writeAndFlush(byteBuf);
}
// public static void sendErrorResponse(Msg msg, GeneratedMessage error_message, int msgId) throws Exception {
// String protoEntity = Base64.getEncoder().encodeToString(error_message.toByteArray());
// BaseGlobal.redisApp.hset(RedisKey.RESPONSE, String.valueOf(msg.getUid()), String.valueOf(Math.abs(msg.getIndex())), new ProtoEntity(msgId, protoEntity), -1);