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:47

🏷️ Properties

compressionThreshold private

ts
compressionThreshold: number = -1

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

connection private

ts
connection: Socket = ...

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

enableCompression private

ts
enableCompression: boolean = false

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

inbound private

ts
inbound: Writable

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

listened private

ts
listened: boolean = false

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

outbound private

ts
outbound: Writable

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

state

ts
state: keyof States = 'handshake'

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

states private readonly

ts
states: Object = ...

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

🔑 Accessors

ready

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

🔧 Methods

disconnect

ts
disconnect(): Promise<void>

Return Type

  • Promise<void>

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

findCoderById

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

Parameters

  • packetId: number
  • side: Side

Return Type

  • Coder<any>

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

getPacketId

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

Parameters

  • packetInst: any
  • side: Side

Return Type

  • number

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

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:104

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:172

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:162

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:173

oncePacket

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

Parameters

  • packet: Function
  • listener: Function

Return Type

  • Channel

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

registerPacket

ts
registerPacket(entry: PacketRegistryEntry): void

Parameters

  • entry: PacketRegistryEntry

Return Type

  • void

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

registerPacketType

ts
registerPacketType(clazz: Function): void

Parameters

  • clazz: Function

Return Type

  • void

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

send

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

Sent a packet to server.

Parameters

  • message: T
  • skeleton: Partial<T>

Return Type

  • Promise<void>

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