better typed packetIds
This commit is contained in:
parent
5af80ad18f
commit
c422bf2fe9
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"101": "DebugNotify",
|
"DebugNotify": "101",
|
||||||
"5": "PlayerGetTokenCsReq",
|
"PlayerGetTokenCsReq": "5",
|
||||||
"48": "PlayerGetTokenScRsp",
|
"PlayerGetTokenScRsp": "48",
|
||||||
"22": "PlayerKeepAliveNotify"
|
"PlayerKeepAliveNotify": "22"
|
||||||
}
|
}
|
@ -2,16 +2,21 @@ import Logger, { VerboseLevel } from "../../util/Logger";
|
|||||||
import protobuf from 'protobufjs';
|
import protobuf from 'protobufjs';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import _packetIds from '../../data/packetIds.json';
|
import _packetIds from '../../data/packetIds.json';
|
||||||
const packetIds = _packetIds as { [key: string]: string };
|
|
||||||
const switchedPacketIds: { [key: string]: number } = (function () {
|
|
||||||
const obj: { [key: string]: number } = {};
|
|
||||||
|
|
||||||
Object.keys(packetIds).forEach((key) => {
|
|
||||||
obj[packetIds[key]] = Number(key);
|
export type PacketTypes = keyof typeof _packetIds;
|
||||||
|
const switchedPacketIds = _packetIds as { [key in PacketTypes]: string };
|
||||||
|
const packetIds: { [key: string]: PacketTypes } = (function () {
|
||||||
|
const obj: { [key: string]: PacketTypes } = {};
|
||||||
|
|
||||||
|
Object.keys(switchedPacketIds).forEach((key) => {
|
||||||
|
obj[switchedPacketIds[key as PacketTypes]] = key as PacketTypes;
|
||||||
});
|
});
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
const c = new Logger("Packet")
|
const c = new Logger("Packet")
|
||||||
|
|
||||||
export default class Packet {
|
export default class Packet {
|
||||||
|
Loading…
Reference in New Issue
Block a user