From 55fa85227fc957992c3e9a6e10b3b10cceac0acf Mon Sep 17 00:00:00 2001 From: godotg Date: Sat, 9 Sep 2023 08:22:33 +0800 Subject: [PATCH] doc[protocol]: update readme --- protocol/README.md | 15 ++------------- protocol/README_CN.md | 12 ++---------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/protocol/README.md b/protocol/README.md index 4c8f3b42..6bfb2a56 100644 --- a/protocol/README.md +++ b/protocol/README.md @@ -122,17 +122,6 @@ For complex objects, ZFOO package size 2216, KRYO package size 2528, and Protobu - The protocol class must be a simple javabean, not inheriting from any other class, but can inherit an interface -- In order to prevent objects in the code and avoid some potential concurrency problems caused by the mixing of objects - in the protocol layer and the po layer, zfoo mandates that protocol classes must implement the IPacket interface - -``` -Now the interface of IPacket is just an identification interface, inheriting the design of IPacket is mainly to make -the code more elegant and easier to understand, and it is not a lot of work to inherit only Object - -The design of inheriting IPacket also has cross-language considerations, which greatly simplifies the difficulty -of serialization and deserialization in other languages and unifies the code implementation of other languages -``` - - The protocol number is defined as a short type to reduce the packet size and memory size, a packet can be reduced by 2 bytes, and the application memory of each protocol can also be reduced by 6 byte(protocols + IProtocolRegistration + protocolIdMap) @@ -146,7 +135,7 @@ your protocol number a little more compactly, so that your protocol number will - The first uses annotations: @Protocol(id = protocolId) ``` @Protocol(id = 104) - public class SimpleObject implements IPacket { + public class SimpleObject { public int c; public boolean g; @@ -158,7 +147,7 @@ your protocol number a little more compactly, so that your protocol number will - The second use: Register the agreement through Protocol Manager.initProtocolAuto() without writing the protocol number ``` - public class SimpleObject implements IPacket { + public class SimpleObject { public int c; diff --git a/protocol/README_CN.md b/protocol/README_CN.md index feeffbed..6a8f0698 100644 --- a/protocol/README_CN.md +++ b/protocol/README_CN.md @@ -99,14 +99,6 @@ cpu: i9900k - 协议类必须是简单的javabean,不能继承任何其它的类,但是可以继承接口 -- 为了防止代码里Object满天飞,避免协议层和po层混用对象造成一些潜在的并发问题,zfoo强制要求协议类必须实现IPacket接口 - -``` -现在IPacket的接口只是一个标识接口,继承IPacket的设计主要是为了让代码更优雅,容易理解一点,改为只继承Object也并没有很大工作量 - -继承IPacket的设计还有跨语言层面上的考虑,极大的简化了实现其它语言的序列化和反序列化难度,统一了其它语言的代码实现 -``` - - 协议号定义为short类型是为了减少包体积和内存大小,一个包可以减少2个byte,每个协议的在应用内存也可以降低6byte(protocols + IProtocolRegistration + protocolIdMap) @@ -118,7 +110,7 @@ cpu: i9900k - 第一种使用注解:@Protocol(id = protocolId) ``` @Protocol(id = 104) - public class SimpleObject implements IPacket { + public class SimpleObject { public int c; public boolean g; @@ -128,7 +120,7 @@ cpu: i9900k - 第二种使用:通过ProtocolManager.initProtocolAuto()去注册协议就可以不写协议号 ``` - public class SimpleObject implements IPacket { + public class SimpleObject { public int c;