mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-14 22:17:50 +00:00
ref[route]: refactor the routing rules for message packets
This commit is contained in:
1 parent
e0064ec720
commit
0041a7ad31
5 files changed
+11
-33
No files matched your search
@@ -124,9 +124,6 @@ public abstract class EnhanceUtils {
|
||||
constructorFiled.setModifiers(Modifier.PRIVATE);
|
||||
enhanceClazz.addField(constructorFiled);
|
||||
|
||||
CtField receiverFiled = new CtField(classPool.get(Object.class.getCanonicalName()), "receiver", enhanceClazz);
|
||||
receiverFiled.setModifiers(Modifier.PRIVATE);
|
||||
enhanceClazz.addField(receiverFiled);
|
||||
|
||||
// 定义类所包含的所有子协议成员
|
||||
var allSubProtocolIds = ProtocolAnalysis.getAllSubProtocolIds(protocolId)
|
||||
@@ -157,11 +154,6 @@ public abstract class EnhanceUtils {
|
||||
protocolConstructorMethod.setBody("{return this.constructor;}");
|
||||
enhanceClazz.addMethod(protocolConstructorMethod);
|
||||
|
||||
CtMethod receiverMethod = new CtMethod(classPool.get(Object.class.getCanonicalName()), "receiver", null, enhanceClazz);
|
||||
receiverMethod.setModifiers(Modifier.PUBLIC + Modifier.FINAL);
|
||||
receiverMethod.setBody("{return this.receiver;}");
|
||||
enhanceClazz.addMethod(receiverMethod);
|
||||
|
||||
CtMethod moduleMethod = new CtMethod(classPool.get(byte.class.getCanonicalName()), "module", null, enhanceClazz);
|
||||
moduleMethod.setModifiers(Modifier.PUBLIC + Modifier.FINAL);
|
||||
moduleMethod.setBody("{return " + registration.module() + ";}");
|
||||
|
||||
@@ -30,11 +30,6 @@ public interface IProtocolRegistration {
|
||||
|
||||
Constructor<?> protocolConstructor();
|
||||
|
||||
/**
|
||||
* 协议接收器,回调方法,主要是存放一些额外的参数
|
||||
*/
|
||||
Object receiver();
|
||||
|
||||
/**
|
||||
* 序列化
|
||||
*/
|
||||
|
||||
@@ -37,12 +37,8 @@ public class ProtocolRegistration implements IProtocolRegistration {
|
||||
private short id;
|
||||
private byte module;
|
||||
private Constructor<?> constructor;
|
||||
|
||||
private Object receiver;
|
||||
|
||||
private Field[] fields;
|
||||
|
||||
|
||||
/**
|
||||
* 所有的协议里的发送顺序都是按字段名称排序
|
||||
*/
|
||||
@@ -67,11 +63,6 @@ public class ProtocolRegistration implements IProtocolRegistration {
|
||||
return constructor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object receiver() {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, IPacket packet) {
|
||||
|
||||
Reference in new issue
Block a user