mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-20 05:27:48 +00:00
perf[protocol]: 使用模板生成协议
This commit is contained in:
@@ -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