mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-19 21:26:08 +00:00
perf[protocol]: 让javascript的协议自动初始化
This commit is contained in:
@@ -7,8 +7,6 @@ describe('jsProtocolTest', () => {
|
||||
it('complexObjectTest', () => {
|
||||
const data = fs.readFileSync('../resources/ComplexObject.bytes');
|
||||
|
||||
ProtocolManager.initProtocol();
|
||||
|
||||
const arrayBytes = new Uint8Array(data.length);
|
||||
data.copy(arrayBytes, 0, 0, data.length);
|
||||
|
||||
|
||||
@@ -6,7 +6,14 @@ import SimpleObject from './packet/SimpleObject.js';
|
||||
|
||||
const protocols = new Map();
|
||||
|
||||
const ProtocolManager = protocols.set(100, ComplexObject); protocols.set(101, NormalObject); protocols.set(102, ObjectA); protocols.set(103, ObjectB); protocols.set(104, SimpleObject);
|
||||
const ProtocolManager = {};
|
||||
|
||||
// initProtocol
|
||||
protocols.set(100, ComplexObject);
|
||||
protocols.set(101, NormalObject);
|
||||
protocols.set(102, ObjectA);
|
||||
protocols.set(103, ObjectB);
|
||||
protocols.set(104, SimpleObject);
|
||||
|
||||
ProtocolManager.getProtocol = function getProtocol(protocolId) {
|
||||
const protocol = protocols.get(protocolId);
|
||||
@@ -30,8 +37,4 @@ ProtocolManager.read = function read(buffer) {
|
||||
return packet;
|
||||
};
|
||||
|
||||
ProtocolManager.initProtocol = function initProtocol() {
|
||||
{}
|
||||
};
|
||||
|
||||
export default ProtocolManager;
|
||||
|
||||
Reference in New Issue
Block a user