mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-13 22:16:32 +00:00
perf[protocol]: import IByteBuffer
This commit is contained in:
1 parent
bb96108784
commit
7354019db1
2 files changed
+6
-4
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
{}
|
{}
|
||||||
|
import IByteBuffer from "./IByteBuffer";
|
||||||
|
|
||||||
const protocols = new Map<number, any>();
|
const protocols = new Map<number, any>();
|
||||||
|
|
||||||
@@ -14,14 +15,14 @@ class ProtocolManager {
|
|||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
static write(buffer: any, packet: any): void {
|
static write(buffer: IByteBuffer, packet: any): void {
|
||||||
const protocolId = packet.protocolId();
|
const protocolId = packet.protocolId();
|
||||||
buffer.writeShort(protocolId);
|
buffer.writeShort(protocolId);
|
||||||
const protocol = ProtocolManager.getProtocol(protocolId);
|
const protocol = ProtocolManager.getProtocol(protocolId);
|
||||||
protocol.write(buffer, packet);
|
protocol.write(buffer, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static read(buffer: any): any {
|
static read(buffer: IByteBuffer): any {
|
||||||
const protocolId = buffer.readShort();
|
const protocolId = buffer.readShort();
|
||||||
const protocol = ProtocolManager.getProtocol(protocolId);
|
const protocol = ProtocolManager.getProtocol(protocolId);
|
||||||
const packet = protocol.read(buffer);
|
const packet = protocol.read(buffer);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import NormalObject from './packet/NormalObject';
|
|||||||
import ObjectA from './packet/ObjectA';
|
import ObjectA from './packet/ObjectA';
|
||||||
import ObjectB from './packet/ObjectB';
|
import ObjectB from './packet/ObjectB';
|
||||||
import SimpleObject from './packet/SimpleObject';
|
import SimpleObject from './packet/SimpleObject';
|
||||||
|
import IByteBuffer from "./IByteBuffer";
|
||||||
|
|
||||||
const protocols = new Map<number, any>();
|
const protocols = new Map<number, any>();
|
||||||
|
|
||||||
@@ -26,14 +27,14 @@ class ProtocolManager {
|
|||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
static write(buffer: any, packet: any): void {
|
static write(buffer: IByteBuffer, packet: any): void {
|
||||||
const protocolId = packet.protocolId();
|
const protocolId = packet.protocolId();
|
||||||
buffer.writeShort(protocolId);
|
buffer.writeShort(protocolId);
|
||||||
const protocol = ProtocolManager.getProtocol(protocolId);
|
const protocol = ProtocolManager.getProtocol(protocolId);
|
||||||
protocol.write(buffer, packet);
|
protocol.write(buffer, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static read(buffer: any): any {
|
static read(buffer: IByteBuffer): any {
|
||||||
const protocolId = buffer.readShort();
|
const protocolId = buffer.readShort();
|
||||||
const protocol = ProtocolManager.getProtocol(protocolId);
|
const protocol = ProtocolManager.getProtocol(protocolId);
|
||||||
const packet = protocol.read(buffer);
|
const packet = protocol.read(buffer);
|
||||||
|
|||||||
Reference in new issue
Block a user