diff --git a/src/server/kcp/Packet.ts b/src/server/kcp/Packet.ts index 81f0fd1..0db8cfd 100644 --- a/src/server/kcp/Packet.ts +++ b/src/server/kcp/Packet.ts @@ -17,6 +17,8 @@ const packetIds: { [key: string]: PacketType } = (function () { })(); + +console.log(packetIds.PlayerGetTokenReq) const c = new Logger("Packet") export default class Packet { @@ -30,6 +32,7 @@ export default class Packet { this.data = rawData.subarray(12 + metadataLength, 12 + metadataLength + rawData.readUInt32BE(8)); this.cmdid = this.rawData.readUInt16BE(4); + this.protoName = this.protoName || packetIds[this.cmdid.toString()]; if (this.protoName) { try { diff --git a/src/server/kcp/Session.ts b/src/server/kcp/Session.ts index da90c1a..55e0686 100644 --- a/src/server/kcp/Session.ts +++ b/src/server/kcp/Session.ts @@ -3,7 +3,7 @@ import { RemoteInfo } from 'dgram'; import { resolve } from 'path'; import fs from 'fs'; import KCP from 'node-kcp-token'; -import Packet from './Packet'; +import Packet, { PacketType } from './Packet'; import Logger, { VerboseLevel } from '../../util/Logger'; import defaultHandler from '../packets/PacketHandler'; @@ -71,7 +71,7 @@ export default class Session { }); } - public send(name: string, body: {}) { + public send(name: PacketType, body: {}) { const packet = Packet.encode(name, body); if (!packet) return; if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(packet.protoName);