mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-23 02:16:31 +00:00
perf[protocol]: 使用模板生成协议
This commit is contained in:
1 parent
6a8aa811a0
commit
29ee2b0d90
30 files changed
+307
-294
No files matched your search
@@ -0,0 +1,28 @@
|
||||
// @author jaysunxiao
|
||||
// @version 3.0
|
||||
const ObjectB = function(flag) {
|
||||
this.flag = flag; // boolean
|
||||
};
|
||||
|
||||
ObjectB.prototype.protocolId = function() {
|
||||
return 103;
|
||||
};
|
||||
|
||||
ObjectB.write = function(buffer, packet) {
|
||||
if (buffer.writePacketFlag(packet)) {
|
||||
return;
|
||||
}
|
||||
buffer.writeBoolean(packet.flag);
|
||||
};
|
||||
|
||||
ObjectB.read = function(buffer) {
|
||||
if (!buffer.readBoolean()) {
|
||||
return null;
|
||||
}
|
||||
const packet = new ObjectB();
|
||||
const result0 = buffer.readBoolean();
|
||||
packet.flag = result0;
|
||||
return packet;
|
||||
};
|
||||
|
||||
export default ObjectB;
|
||||
Reference in new issue
Block a user