Skip to content

Commit

Permalink
refactor: Adjust the channel
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Nov 21, 2023
1 parent 71e49a9 commit c7c5106
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/client/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export class Channel extends EventEmitter {
this.inbound
.pipe(new PacketDecompress({
get enableCompression() {
return this.enableCompression
return false
},
get compressionThreshold() {
return this.compressionThreshold
return -1
},
}))
.pipe(new MinecraftPacketDecoder(this))
Expand Down Expand Up @@ -293,7 +293,8 @@ export abstract class PacketEncoder extends Transform {
this.writePacketId(buf, id)
coder.encode(buf, message, this.client)
buf.flip()
this.push(buf.buffer.slice(0, buf.limit))
const arr = buf.buffer.slice(0, buf.limit)
this.push(Buffer.from(arr))
callback()
} else {
callback(new Error(`Cannot find coder for message. ${JSON.stringify(message)}`))
Expand All @@ -317,7 +318,7 @@ export abstract class PacketOutbound extends Transform {
buffer.append(packet)
buffer.flip()

this.push(buffer.buffer.slice(0, buffer.limit))
this.push(Buffer.from(buffer.buffer.slice(0, buffer.limit)))
callback()
}
}
Expand Down

0 comments on commit c7c5106

Please sign in to comment.