Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
5b18de9941
|
@ -1,6 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Ldb >
|
||||
|
||||
<Jbean name="ItemEntity">
|
||||
<Variable name="id" type="int"/>
|
||||
<Variable name="uniqueid" type="long"/>
|
||||
<Variable name="count" type="int"/>
|
||||
<Variable name="position" type="int"/>包裹属性,位置。从0开始编号
|
||||
<Variable name="createTime" type="int"/>
|
||||
</Jbean>
|
||||
|
||||
<Jbean name="BagEntity">
|
||||
<Variable name="bagid" type="long"/>
|
||||
<Variable name="nextId" type="int"/>
|
||||
<Variable name="capacity" type="int"/>
|
||||
<Variable name="itemMap" type="map" key="int" value="ItemEntity" /> 道具map
|
||||
|
||||
</Jbean>
|
||||
|
||||
|
||||
<Jbean name="BagManager">背包管理器
|
||||
<Variable name="bagMap" type="map" key="int" value="BagEntity" />背包map
|
||||
</Jbean>
|
||||
|
||||
|
||||
<Jbean name="PropertyItem">
|
||||
<Variable name="id" type="string"/>
|
||||
<Variable name="equipId" type="int"/>
|
||||
|
|
|
@ -40,6 +40,20 @@ class JbeanFormatter {
|
|||
ps.println(" public " + cls + "() {");
|
||||
ps.println(" }");
|
||||
ps.println();
|
||||
|
||||
ps.println();
|
||||
ps.println(" public " + cls + "(" + cls + " _o_ ) {");
|
||||
variables.forEach(var -> VarDeepCopy.make(var, ps, " "));
|
||||
ps.println(" }");
|
||||
ps.println();
|
||||
|
||||
|
||||
//
|
||||
// ps.println(" public void copyFrom(" + cls + " _o_) {");
|
||||
// variables.forEach(var -> VarCopyFrom.make(var, ps, " "));
|
||||
// ps.println(" }");
|
||||
// ps.println();
|
||||
|
||||
//MethodSetMongoKey.make(variables, ps, " ");
|
||||
// getter setter
|
||||
variables.forEach(var -> MethodVarGetter.make(var, ps, " "));
|
||||
|
|
|
@ -35,17 +35,21 @@ import util.StringUtil;
|
|||
import util.TimeUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息类型-消息处理 管理
|
||||
* 11.22 之前部分功能拆分至sessionmanager
|
||||
*
|
||||
* 4.21
|
||||
* 协议号自动映射
|
||||
* 目的:省去手动注册协议号和发送填写协议号带来的错误 简化过程
|
||||
* 新增协议的handler定义 协议名+Handler e.g: ModItemNumIndication -> ModItemNumIndicationHandler
|
||||
* 新增协议号使用协议名定义
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class ProtocolsManager implements ProtocolsAbstract {
|
||||
|
@ -81,11 +85,29 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
|
||||
private void addHandler(BaseHandler handler) {
|
||||
if(null==handler.getMessageCode()){
|
||||
String simpleName = handler.getClass().getSimpleName();
|
||||
int index = simpleName.indexOf("Handler");
|
||||
if(index != -1)
|
||||
{
|
||||
simpleName = simpleName.substring(0, index);
|
||||
int number = getProtoIdBySimpleName(simpleName);
|
||||
handlers.put(number, handler);
|
||||
}
|
||||
return;
|
||||
}
|
||||
handlers.put(handler.getMessageCode().getNumber(), handler);
|
||||
}
|
||||
|
||||
public static int getProtoIdBySimpleName(String name){
|
||||
try {
|
||||
MessageTypeProto.MessageType messageType = MessageTypeProto.MessageType.valueOf(name);
|
||||
return messageType.getNumber();
|
||||
}catch (IllegalArgumentException e){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void processMessage(PacketNetData packetNetData) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.dao.UserManager;
|
|||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.netty.PackageConstant;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.*;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
|
@ -60,7 +61,9 @@ public class MessageUtil {
|
|||
System.arraycopy(backMessage, 0, bytes, pos, backMessage.length);
|
||||
}
|
||||
int[] secretKey = Tea.KEY;
|
||||
return Tea.encrypt2(bytes, secretKey);
|
||||
byte[] bytes1 = Tea.encrypt2(bytes, secretKey);
|
||||
LOGGER.info("sendbyte"+bytes1.length);
|
||||
return bytes1;
|
||||
}
|
||||
|
||||
public static void sendMessage(int[] uids, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||
|
@ -140,6 +143,28 @@ public class MessageUtil {
|
|||
session.putBackIndicationToMap(indicationIndex,byteBuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 协议号 大于30000 自动进行协议号查找
|
||||
* @param generatedMessage
|
||||
*/
|
||||
public static void sendIndicationMessage(int uid, GeneratedMessage generatedMessage) {
|
||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
||||
if(null == session){
|
||||
return;
|
||||
}
|
||||
if(session.getFiveReady() == 0){
|
||||
return;
|
||||
}
|
||||
int indicationIndex = session.getIndicationIndex();
|
||||
int msgId = ProtocolsManager.getProtoIdBySimpleName(generatedMessage.getClass().getSimpleName());
|
||||
if(msgId==0){
|
||||
return;
|
||||
}
|
||||
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), indicationIndex,1, msgId, generatedMessage);
|
||||
session.write(byteBuf,true);
|
||||
session.putBackIndicationToMap(indicationIndex,byteBuf);
|
||||
}
|
||||
|
||||
public static void retrySendIndication( ISession session, byte[] byteBuf){
|
||||
session.writeAndFlush(byteBuf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue