Skip to content

Class Channel

The channel for send and listen the Minecraft packet.

🏭 Constructors

constructor

ts
new Channel(): Channel

Return Type

  • Channel

Defined in: packages/client/channel.ts:46

🏷️ Properties

compressionThreshold

ts
compressionThreshold: number = -1

Defined in: packages/client/channel.ts:44

connection

ts
connection: Socket = ...

Defined in: packages/client/channel.ts:38

enableCompression

ts
enableCompression: boolean = false

Defined in: packages/client/channel.ts:43

inbound

ts
inbound: Writable

Defined in: packages/client/channel.ts:41

outbound

ts
outbound: Writable

Defined in: packages/client/channel.ts:40

state

ts
state: keyof States = 'handshake'

Defined in: packages/client/channel.ts:21

states

ts
states: Object = ...

Defined in: packages/client/channel.ts:23

🔑 Accessors

ready

Defined in: packages/client/channel.ts:70

🔧 Methods

disconnect

ts
disconnect(): Promise<void>

Return Type

  • Promise<void>

Defined in: packages/client/channel.ts:122

findCoderById

ts
findCoderById(packetId: number, side: Side): Coder<any>

Parameters

  • packetId: number
  • side: Side

Return Type

  • Coder<any>

Defined in: packages/client/channel.ts:74

getPacketId

ts
getPacketId(packetInst: any, side: Side): number

Parameters

  • packetInst: any
  • side: Side

Return Type

  • number

Defined in: packages/client/channel.ts:79

listen

ts
listen(option: Object): Promise<void>

Open the connection and start to listen the port.

Parameters

  • option: Object

Return Type

  • Promise<void>

Defined in: packages/client/channel.ts:103

on

ts
on(channel: string, listener: Function): Channel

Parameters

  • channel: string
  • listener: Function

Return Type

  • Channel

Inherited from: EventEmitter.on

Defined in: packages/client/channel.ts:161

onPacket

ts
onPacket(packet: Function, listener: Function): Channel

Listen for sepcific packet by its class name.

Parameters

  • packet: Function
  • listener: Function

Return Type

  • Channel

Defined in: packages/client/channel.ts:151

once

ts
once(channel: string, listener: Function): Channel

Parameters

  • channel: string
  • listener: Function

Return Type

  • Channel

Inherited from: EventEmitter.once

Defined in: packages/client/channel.ts:162

oncePacket

ts
oncePacket(packet: Function, listener: Function): Channel

Parameters

  • packet: Function
  • listener: Function

Return Type

  • Channel

Defined in: packages/client/channel.ts:155

registerPacket

ts
registerPacket(entry: PacketRegistryEntry): void

Parameters

  • entry: PacketRegistryEntry

Return Type

  • void

Defined in: packages/client/channel.ts:93

registerPacketType

ts
registerPacketType(clazz: Function): void

Parameters

  • clazz: Function

Return Type

  • void

Defined in: packages/client/channel.ts:85

send

ts
send(message: T, skeleton: Partial<T>): void

Sent a packet to server.

Parameters

  • message: T
  • skeleton: Partial<T>

Return Type

  • void

Defined in: packages/client/channel.ts:141

Released under the MIT License.