class Networking

extends

EventEmitter
export declare class Networking extends EventEmitter

Manages the networking required to maintain a voice connection and dispatch audio packets

Constructors

constructor(
debug: boolean
)

Creates a new Networking instance.

The current state of the networking instance.

destroy() : void

Destroys the Networking instance, transitioning it into the Closed state.

dispatchAudio() : boolean

Dispatches the audio packet previously prepared by prepareAudioPacket(opusPacket). The audio packet is consumed and cannot be dispatched again.

prepareAudioPacket(
opusPacket: Buffer
) : Buffer | undefined

Prepares an Opus packet for playback. This includes attaching metadata to it and encrypting it. It will be stored within the instance, and can be played by dispatchAudio()

Returns: The audio packet that was prepared

setSpeaking(
speaking: boolean
) : void

Sends a packet to the voice gateway indicating that the client has start/stopped sending audio.

on(
event: 'debug'
listener: (message: string) => void
) : this

Debug event for Networking.