Skip to content

Commit

Permalink
给个类型
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jul 14, 2022
1 parent 7385432 commit d57501a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {Duplex} from 'stream'
import {Container} from 'typedi'
import {Backend} from './backend'
import {Config} from './config'
import {IPacket} from './constants'
import {MinecraftData} from './minecraft-data'
import {ProxyServer} from './proxy-server'
import ms = require('ms')
Expand Down Expand Up @@ -75,9 +76,9 @@ export class Client extends EventEmitter {
if (this.host) return
this.state = states.HANDSHAKING
for await (const chunk of this.splitter) {
const packet = this.deserializer.parsePacketBuffer(chunk)
const packet: IPacket = this.deserializer.parsePacketBuffer(chunk)
const {name, params} = packet.data
this.logger.trace({packet, state: this.state})
this.logger.trace({packetData: packet.data, state: this.state})
switch (name) {
case 'set_protocol':
this.protocolVersion = params.protocolVersion
Expand Down
9 changes: 9 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import {PacketMeta} from 'minecraft-protocol'

export enum EnumHandShakeState {
status = 1,
login = 2,
}

export interface IPacket<T = any> {
data: T
packetMeta: PacketMeta
buffer: Buffer
fullBuffer: Buffer
}

0 comments on commit d57501a

Please sign in to comment.