Skip to content

Commit

Permalink
修正日志
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jul 12, 2022
1 parent cd74162 commit 824f23e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import is from '@sindresorhus/is'
import {createLogger} from 'bunyan'
import {createHash} from 'crypto'
import {EventEmitter, once} from 'events'
import got from 'got'
import {pick} from 'lodash'
import {createDeserializer, createSerializer, states, States} from 'minecraft-protocol'
import * as framing from 'minecraft-protocol/src/transforms/framing'
import {connect, Socket} from 'net'
import {AddressInfo, connect, Socket} from 'net'
import {Duplex} from 'stream'
import {Container} from 'typedi'
import {Backend} from './backend'
Expand Down Expand Up @@ -219,7 +220,7 @@ export class Client extends EventEmitter {
try {
this.write('disconnect', {reason: JSON.stringify({text: reason})})
this._closed = true
this.logger.info(`force disconnecting ${this.socket.address()}, reason: ${reason}`)
this.logger.info(`force disconnecting ${addressToString(this.socket.address())}, reason: ${reason}`)
} catch (err) {
this.logger.warn(err, 'failed to disconnect')
this.kill()
Expand All @@ -234,3 +235,8 @@ export class Client extends EventEmitter {
this.serializer.write({name, params})
}
}

function addressToString(address: AddressInfo | string): string {
if (is.string(address)) return address
return `${address.address}:${address.port}`
}

0 comments on commit 824f23e

Please sign in to comment.