perf[protocol]: 使用模板生成协议

This commit is contained in:
jaysunxiao
2022-05-16 20:54:14 +08:00
parent 6a8aa811a0
commit 29ee2b0d90
30 changed files with 307 additions and 294 deletions
@@ -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;