DiscordPHP Documentation

VoiceClient extends EventEmitter
in package

The Discord voice client.

Tags
since
3.2.0

Table of Contents

Constants

DCA_VERSION  = 'DCA1'
The DCA version the client is using.
DEPRECATED_MODES  = ['xsalsa20_poly1305']
SILENCE_FRAME  = "\xf8\xff\xfe"
The Opus Silence Frame.
SUPPORTED_MODES  = ['aead_aes256_gcm_rtpsize', 'aead_xchacha20_poly1305_rtpsize']
UNSUPPORTED_MODES  = ['xsalsa20_poly1305_lite_rtpsize', 'aead_aes256_gcm', 'xsalsa20_poly1305_suffix', 'xsalsa20_poly1305_lite']
VOICE_OP_HANDLERS  = [\Discord\WebSockets\Op::VOICE_READY => 'handleReady', \Discord\WebSockets\Op::VOICE_SESSION_DESCRIPTION => 'handleSessionDescription', \Discord\WebSockets\Op::VOICE_SPEAKING => 'handleSpeaking', \Discord\WebSockets\Op::VOICE_HEARTBEAT_ACK => 'heartbeatAck', \Discord\WebSockets\Op::VOICE_HELLO => 'handleHello', \Discord\WebSockets\Op::VOICE_RESUMED => 'handleResumed', \Discord\WebSockets\Op::VOICE_CLIENT_CONNECT => 'handleClientConnect', \Discord\WebSockets\Op::VOICE_CLIENT_DISCONNECT => 'handleClientDisconnect', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_TRANSITION => 'handleDavePrepareTransition', \Discord\WebSockets\Op::VOICE_DAVE_EXECUTE_TRANSITION => 'handleDaveExecuteTransition', \Discord\WebSockets\Op::VOICE_DAVE_TRANSITION_READY => 'handleDaveTransitionReady', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_EPOCH => 'handleDavePrepareEpoch', \Discord\WebSockets\Op::VOICE_DAVE_MLS_EXTERNAL_SENDER => 'handleDaveMlsExternalSender', \Discord\WebSockets\Op::VOICE_DAVE_MLS_KEY_PACKAGE => 'handleDaveMlsKeyPackage', \Discord\WebSockets\Op::VOICE_DAVE_MLS_PROPOSALS => 'handleDaveMlsProposals', \Discord\WebSockets\Op::VOICE_DAVE_MLS_COMMIT_WELCOME => 'handleDaveMlsCommitWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_ANNOUNCE_COMMIT_TRANSITION => 'handleDaveMlsAnnounceCommitTransition', \Discord\WebSockets\Op::VOICE_DAVE_MLS_WELCOME => 'handleDaveMlsWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_INVALID_COMMIT_WELCOME => 'handleDaveMlsInvalidCommitWelcome']

Properties

$client  : Socket
The UDP client.
$ssrc  : int
The SSRC value.
$audioApplication  : string
The audio application to encode with.
$bitrate  : int
The bitrate to encode with.
$buffer  : Buffer
Audio Buffer.
$channel  : Channel
The Channel that we are connecting to.
$data  : array<string|int, mixed>
Data from the main WebSocket.
$dca  : string
The DCA binary name that we will use.
$deaf  : bool
Whether we are set as deaf.
$dnsConfig  : string|Config
The Config for DNS Resolver.
$endpoint  : string
The Voice WebSocket endpoint.
$ffmpeg  : string
The FFmpeg binary location.
$frameSize  : int
The size of audio frames, in milliseconds.
$heartbeat  : TimerInterface
The Voice WebSocket heartbeat timer.
$heartbeat_interval  : int
The UDP heartbeat interval.
$heartbeatSeq  : int
The UDP heartbeat sequence.
$logger  : LoggerInterface
The logger.
$loop  : LoopInterface
The ReactPHP event loop.
$mainWebsocket  : WebSocket
The main WebSocket instance.
$mode  : string
The Voice WebSocket mode.
$mute  : bool
Whether we are set as mute.
$paused  : bool
Whether the voice client is currently paused.
$protocol  : string
The Voice connection protocol.
$readOpusTimer  : TimerInterface
readopus Timer.
$ready  : bool
Is the voice client ready?
$recieveStreams  : array<string|int, mixed>
Voice audio recieve streams.
$reconnecting  : bool
Is the voice client reconnecting?
$secret_key  : string
The secret key used for encrypting voice.
$sentLoginFrame  : bool
Have we sent the login frame yet?
$seq  : int
The sequence of audio packets being sent.
$silenceRemaining  : int
Silence Frame Remain Count.
$speaking  : bool
Are we currently set as speaking?
$speakingStatus  : ExCollectionInterface
Collection of the status of people speaking.
$startTime  : int
The time we started sending packets.
$streamTime  : int
The stream time of the last packet.
$supportedModes  : array<string|int, string>
The supported transport encryption modes the voice server expects.
$timestamp  : int
The timestamp of the last packet.
$udpHeartbeat  : TimerInterface
The UDP heartbeat timer.
$udpIp  : string
The IP the UDP client will use.
$udpPort  : int
The port the UDP client will use.
$userClose  : bool
Is the voice client being closed by user?
$version  : int
The Discord voice gateway version.
$voiceDecoders  : ExCollectionInterface
Collection of voice decoders.
$voiceSessions  : array<string|int, mixed>
The voice sessions.
$voiceWebsocket  : WebSocket
The voice WebSocket instance.
$volume  : int
The volume the audio will be encoded with.

Methods

__construct()  : mixed
Constructs the Voice Client instance.
close()  : void
Closes the voice client.
dcaDecode()  : Process
Decodes a file from Opus with DCA.
ffmpegEncode()  : Process
Creates a process that will run FFmpeg and encode `$filename` into Ogg Opus format.
getChannel()  : Channel
Returns the connected channel.
getRecieveStream()  : RecieveStream
Gets a recieve voice stream.
handleVoiceServerChange()  : void
Handles a voice server change.
handleVoiceStateUpdate()  : void
Handles a voice state update.
handleWebSocketClose()  : void
Handles a WebSocket close.
handleWebSocketConnection()  : void
Handles a WebSocket connection.
handleWebSocketError()  : void
Handles a WebSocket error.
initSockets()  : void
Initilizes the WebSocket and UDP socket.
isPaused()  : bool
Checks if we are paused.
isReady()  : bool
Returns whether the voice client is ready.
isSpeaking()  : bool
Checks if the user is speaking.
pause()  : void
Pauses the current sound.
playDCAStream()  : PromiseInterface
Plays a DCA stream.
playFile()  : PromiseInterface
Plays a file/url on the voice stream.
playOggStream()  : PromiseInterface
Plays an Ogg Opus stream.
playRawStream()  : PromiseInterface
Plays a raw PCM16 stream.
setAudioApplication()  : void
Sets the audio application.
setBitrate()  : void
Sets the bitrate.
setMode()  : void
Sets the transport encryption mode for the voice client.
setMuteDeaf()  : void
Changes your mute and deaf value.
setSpeaking()  : void
Sets the speaking value of the client.
setVolume()  : void
Sets the volume.
start()  : void|bool
Starts the voice client.
stop()  : void
Stops the current sound.
switchChannel()  : void
Switches voice channels.
unpause()  : void
Unpauses the current sound.
checkForExecutable()  : string|null
Checks if an executable exists on the system.
checkForFFmpeg()  : bool
Checks if FFmpeg is installed.
checkForLibsodium()  : bool
Checks if libsodium-php is installed.
decodeUDP()  : void
Decodes a UDP message to extract the IP address and port, then selects the protocol for voice communication.
decryptVoicePacket()  : string|false
generateCommit()  : mixed
generateKeyPackage()  : mixed
generateWelcome()  : mixed
handleAudioData()  : void
Handles raw opus data from the UDP server.
handleClientConnect()  : void
Handles the event when a client connects to the voice server.
handleClientDisconnect()  : void
Handles the event when a client disconnects from the voice server.
handleDaveExecuteTransition()  : void
handleDaveMlsAnnounceCommitTransition()  : void
handleDaveMlsCommitWelcome()  : void
handleDaveMlsExternalSender()  : mixed
handleDaveMlsInvalidCommitWelcome()  : void
handleDaveMlsKeyPackage()  : void
handleDaveMlsProposals()  : void
handleDaveMlsWelcome()  : void
handleDavePrepareEpoch()  : void
handleDavePrepareTransition()  : void
handleDaveTransitionReady()  : void
handleHello()  : void
Handles the "Hello" event from the Discord voice server.
handleReady()  : void
Handles the "ready" event for the voice client, initializing UDP connection and heartbeat.
handleResumed()  : void
Handles the 'resumed' event for the voice client.
handleSessionDescription()  : void
Handles the session description packet received from the Discord voice server.
handleSpeaking()  : void
Handles the speaking state of a user.
heartbeat()  : void
Sends a heartbeat payload to the voice server to maintain the connection.
heartbeatAck()  : void
Handles the heartbeat acknowledgement from the voice WebSocket connection.
identify()  : void
Sends an identify payload to the voice gateway to authenticate the client.
insertSilence()  : void
Insert 5 frames of silence.
mainSend()  : void
Sends a message to the main websocket.
reset()  : void
Resets the voice client.
resume()  : void
Resumes a previously established voice connection.
selectProtocol()  : void
Selects the UDP protocol for the voice connection and sends the selection payload.
send()  : void
Sends a message to the voice websocket.
sendBuffer()  : void
Sends a buffer to the UDP socket.

Constants

DCA_VERSION

The DCA version the client is using.

public string DCA_VERSION = 'DCA1'

The DCA version.

DEPRECATED_MODES

public mixed DEPRECATED_MODES = ['xsalsa20_poly1305']

SILENCE_FRAME

The Opus Silence Frame.

public string SILENCE_FRAME = "\xf8\xff\xfe"

The silence frame.

SUPPORTED_MODES

public mixed SUPPORTED_MODES = ['aead_aes256_gcm_rtpsize', 'aead_xchacha20_poly1305_rtpsize']

UNSUPPORTED_MODES

public mixed UNSUPPORTED_MODES = ['xsalsa20_poly1305_lite_rtpsize', 'aead_aes256_gcm', 'xsalsa20_poly1305_suffix', 'xsalsa20_poly1305_lite']

VOICE_OP_HANDLERS

public mixed VOICE_OP_HANDLERS = [\Discord\WebSockets\Op::VOICE_READY => 'handleReady', \Discord\WebSockets\Op::VOICE_SESSION_DESCRIPTION => 'handleSessionDescription', \Discord\WebSockets\Op::VOICE_SPEAKING => 'handleSpeaking', \Discord\WebSockets\Op::VOICE_HEARTBEAT_ACK => 'heartbeatAck', \Discord\WebSockets\Op::VOICE_HELLO => 'handleHello', \Discord\WebSockets\Op::VOICE_RESUMED => 'handleResumed', \Discord\WebSockets\Op::VOICE_CLIENT_CONNECT => 'handleClientConnect', \Discord\WebSockets\Op::VOICE_CLIENT_DISCONNECT => 'handleClientDisconnect', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_TRANSITION => 'handleDavePrepareTransition', \Discord\WebSockets\Op::VOICE_DAVE_EXECUTE_TRANSITION => 'handleDaveExecuteTransition', \Discord\WebSockets\Op::VOICE_DAVE_TRANSITION_READY => 'handleDaveTransitionReady', \Discord\WebSockets\Op::VOICE_DAVE_PREPARE_EPOCH => 'handleDavePrepareEpoch', \Discord\WebSockets\Op::VOICE_DAVE_MLS_EXTERNAL_SENDER => 'handleDaveMlsExternalSender', \Discord\WebSockets\Op::VOICE_DAVE_MLS_KEY_PACKAGE => 'handleDaveMlsKeyPackage', \Discord\WebSockets\Op::VOICE_DAVE_MLS_PROPOSALS => 'handleDaveMlsProposals', \Discord\WebSockets\Op::VOICE_DAVE_MLS_COMMIT_WELCOME => 'handleDaveMlsCommitWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_ANNOUNCE_COMMIT_TRANSITION => 'handleDaveMlsAnnounceCommitTransition', \Discord\WebSockets\Op::VOICE_DAVE_MLS_WELCOME => 'handleDaveMlsWelcome', \Discord\WebSockets\Op::VOICE_DAVE_MLS_INVALID_COMMIT_WELCOME => 'handleDaveMlsInvalidCommitWelcome']

Properties

$client

The UDP client.

public Socket $client

The voiceUDP client.

$ssrc

The SSRC value.

public int $ssrc

The SSRC value used for RTP.

$audioApplication

The audio application to encode with.

protected string $audioApplication = 'audio'

Available: voip, audio (default), lowdelay

The audio application.

$bitrate

The bitrate to encode with.

protected int $bitrate = 128000

Encoding bitrate.

$channel

The Channel that we are connecting to.

protected Channel $channel

The channel that we are going to connect to.

$data

Data from the main WebSocket.

protected array<string|int, mixed> $data

Information required for the voice WebSocket.

$dca

The DCA binary name that we will use.

protected string $dca

The DCA binary name that will be run.

$deaf

Whether we are set as deaf.

protected bool $deaf = false

Whether we are set as deaf.

$dnsConfig

The Config for DNS Resolver.

protected string|Config $dnsConfig

$endpoint

The Voice WebSocket endpoint.

protected string $endpoint

The endpoint the Voice WebSocket and UDP client will connect to.

$ffmpeg

The FFmpeg binary location.

protected string $ffmpeg

$frameSize

The size of audio frames, in milliseconds.

protected int $frameSize = 20

The size of audio frames.

$heartbeat

The Voice WebSocket heartbeat timer.

protected TimerInterface $heartbeat

The heartbeat periodic timer.

$heartbeat_interval

The UDP heartbeat interval.

protected int $heartbeat_interval

How often we send a heartbeat packet.

$heartbeatSeq

The UDP heartbeat sequence.

protected int $heartbeatSeq = 0

The heartbeat sequence.

$logger

The logger.

protected LoggerInterface $logger

Logger.

$loop

The ReactPHP event loop.

protected LoopInterface $loop

The ReactPHP event loop that will run everything.

$mainWebsocket

The main WebSocket instance.

protected WebSocket $mainWebsocket

The main WebSocket client.

$mode

The Voice WebSocket mode.

protected string $mode = 'aead_aes256_gcm_rtpsize'

The transport encryption mode.

$mute

Whether we are set as mute.

protected bool $mute = false

Whether we are set as mute.

$paused

Whether the voice client is currently paused.

protected bool $paused = false

Whether the voice client is currently paused.

$protocol

The Voice connection protocol.

protected string $protocol = 'udp'

The protocol to use for the voice connection.

$readOpusTimer

readopus Timer.

protected TimerInterface $readOpusTimer

Timer

$ready

Is the voice client ready?

protected bool $ready = false

Whether the voice client is ready.

$recieveStreams

Voice audio recieve streams.

protected array<string|int, mixed> $recieveStreams

Voice audio recieve streams.

$reconnecting

Is the voice client reconnecting?

protected bool $reconnecting = false

Whether the voice client is reconnecting.

$secret_key

The secret key used for encrypting voice.

protected string $secret_key

The secret key.

$sentLoginFrame

Have we sent the login frame yet?

protected bool $sentLoginFrame = false

Whether we have sent the login frame.

$seq

The sequence of audio packets being sent.

protected int $seq = 0

The sequence of audio packets.

$silenceRemaining

Silence Frame Remain Count.

protected int $silenceRemaining = 5

Amount of silence frames remaining.

$speaking

Are we currently set as speaking?

protected bool $speaking = false

Whether we are speaking or not.

$speakingStatus

Collection of the status of people speaking.

protected ExCollectionInterface $speakingStatus

Status of people speaking.

$startTime

The time we started sending packets.

protected int $startTime

The time we started sending packets.

$streamTime

The stream time of the last packet.

protected int $streamTime = 0

The time we sent the last packet.

$supportedModes

The supported transport encryption modes the voice server expects.

protected array<string|int, string> $supportedModes

The supported transport encryption modes.

$timestamp

The timestamp of the last packet.

protected int $timestamp = 0

The timestamp the last packet was constructed.

$udpHeartbeat

The UDP heartbeat timer.

protected TimerInterface $udpHeartbeat

The heartbeat periodic timer.

$udpIp

The IP the UDP client will use.

protected string $udpIp

The IP that the UDP client will connect to.

$udpPort

The port the UDP client will use.

protected int $udpPort

The port that the UDP client will connect to.

$userClose

Is the voice client being closed by user?

protected bool $userClose = false

Whether the voice client is being closed by user.

$version

The Discord voice gateway version.

protected int $version = 8

Voice version.

$voiceDecoders

Collection of voice decoders.

protected ExCollectionInterface $voiceDecoders

Voice decoders.

$voiceSessions

The voice sessions.

protected array<string|int, mixed> $voiceSessions

The voice sessions.

$voiceWebsocket

The voice WebSocket instance.

protected WebSocket $voiceWebsocket

The voice WebSocket client.

$volume

The volume the audio will be encoded with.

protected int $volume = 100

The volume that the audio will be encoded in.

Methods

__construct()

Constructs the Voice Client instance.

public __construct(WebSocket $websocket, LoopInterface $loop, Channel $channel, LoggerInterface $logger, array<string|int, mixed> $data, array<string|int, mixed> &$voiceSessions) : mixed
Parameters
$websocket : WebSocket

The main WebSocket client.

$loop : LoopInterface

The ReactPHP event loop.

$channel : Channel

The channel we are connecting to.

$logger : LoggerInterface

The logger.

$data : array<string|int, mixed>

More information related to the voice client.

$voiceSessions : array<string|int, mixed>

The voice sessions.

close()

Closes the voice client.

public close() : void
Tags
throws
RuntimeException

dcaDecode()

Decodes a file from Opus with DCA.

public dcaDecode([int $channels = 2 ][, int|null $frameSize = null ]) : Process
Parameters
$channels : int = 2

How many audio channels to decode with.

$frameSize : int|null = null

The Opus packet frame size.

Return values
Process

A ReactPHP Child Process

ffmpegEncode()

Creates a process that will run FFmpeg and encode `$filename` into Ogg Opus format.

public ffmpegEncode([string|null $filename = null ][, array<string|int, mixed>|null $preArgs = null ]) : Process

If $filename is null, the process will expect some sort of audio data to be piped in via stdin. It is highly recommended to set $preArgs to contain the format of the piped data when using a pipe as an input. You may also want to provide some arguments to FFmpeg via $preArgs, which will be appended to the FFmpeg command before setting the input arguments.

Parameters
$filename : string|null = null

Path to file to be converted into Ogg Opus, or null for pipe via stdin.

$preArgs : array<string|int, mixed>|null = null

A list of arguments to be appended before the input filename.

Return values
Process

A ReactPHP child process.

getChannel()

Returns the connected channel.

public getChannel() : Channel
Return values
Channel

The connected channel.

getRecieveStream()

Gets a recieve voice stream.

public getRecieveStream(int|string $id) : RecieveStream
Parameters
$id : int|string

Either a SSRC or User ID.

Return values
RecieveStream

handleVoiceServerChange()

Handles a voice server change.

public handleVoiceServerChange([array<string|int, mixed> $data = [] ]) : void
Parameters
$data : array<string|int, mixed> = []

New voice server information.

handleVoiceStateUpdate()

Handles a voice state update.

public handleVoiceStateUpdate(Payload $data) : void

NOTE: This object contains the data as the VoiceStateUpdate Part.

Parameters
$data : Payload

The WebSocket data.

Tags
see
VoiceStateUpdate

handleWebSocketClose()

Handles a WebSocket close.

public handleWebSocketClose(int $op, string $reason) : void
Parameters
$op : int
$reason : string

handleWebSocketConnection()

Handles a WebSocket connection.

public handleWebSocketConnection(WebSocket $ws) : void
Parameters
$ws : WebSocket

The WebSocket instance.

handleWebSocketError()

Handles a WebSocket error.

public handleWebSocketError(Exception $e) : void
Parameters
$e : Exception

The error.

initSockets()

Initilizes the WebSocket and UDP socket.

public initSockets() : void

isPaused()

Checks if we are paused.

public isPaused() : bool
Return values
bool

Whether we are paused.

isReady()

Returns whether the voice client is ready.

public isReady() : bool
Return values
bool

Whether the voice client is ready.

isSpeaking()

Checks if the user is speaking.

public isSpeaking([string|int|null $id = null ]) : bool
Parameters
$id : string|int|null = null

Either the User ID or SSRC (if null, return bots speaking status).

Return values
bool

Whether the user is speaking.

pause()

Pauses the current sound.

public pause() : void
Tags
throws
RuntimeException

playDCAStream()

Plays a DCA stream.

public playDCAStream(resource|Process|ReadableResourceStream $stream) : PromiseInterface

DCA is now deprecated in DiscordPHP, switch to using playOggStream with raw Ogg Opus.

Parameters
$stream : resource|Process|ReadableResourceStream

The DCA stream to be sent.

Tags
throws
Exception
Return values
PromiseInterface

playFile()

Plays a file/url on the voice stream.

public playFile(string $file[, int $channels = 2 ]) : PromiseInterface
Parameters
$file : string

The file/url to play.

$channels : int = 2

Deprecated, Discord only supports 2 channels.

Tags
throws
FileNotFoundException
throws
RuntimeException
Return values
PromiseInterface

playOggStream()

Plays an Ogg Opus stream.

public playOggStream(resource|Process|ReadableResourceStream $stream) : PromiseInterface
Parameters
$stream : resource|Process|ReadableResourceStream

The Ogg Opus stream to be sent.

Tags
throws
RuntimeException
throws
InvalidArgumentException
Return values
PromiseInterface

playRawStream()

Plays a raw PCM16 stream.

public playRawStream(resource|ReadableResourceStream $stream[, int $channels = 2 ][, int $audioRate = 48000 ]) : PromiseInterface
Parameters
$stream : resource|ReadableResourceStream

The stream to be encoded and sent.

$channels : int = 2

How many audio channels the PCM16 was encoded with.

$audioRate : int = 48000

Audio sampling rate the PCM16 was encoded with.

Tags
throws
RuntimeException
throws
InvalidArgumentException

Thrown when the stream passed to playRawStream is not a valid resource.

Return values
PromiseInterface

setAudioApplication()

Sets the audio application.

public setAudioApplication(string $app) : void
Parameters
$app : string

The audio application to set.

Tags
throws
DomainException
throws
RuntimeException

setBitrate()

Sets the bitrate.

public setBitrate(int $bitrate) : void
Parameters
$bitrate : int

The bitrate to set.

Tags
throws
DomainException
throws
RuntimeException

setMode()

Sets the transport encryption mode for the voice client.

public setMode(string $mode) : void
Parameters
$mode : string

The transport encryption mode to set for the voice client.

Tags
throws
InvalidArgumentException

If the provided mode is not supported.

setMuteDeaf()

Changes your mute and deaf value.

public setMuteDeaf(bool $mute, bool $deaf) : void
Parameters
$mute : bool

Whether you should be muted.

$deaf : bool

Whether you should be deaf.

Tags
throws
RuntimeException

setSpeaking()

Sets the speaking value of the client.

public setSpeaking([bool $speaking = true ]) : void
Parameters
$speaking : bool = true

Whether the client is speaking or not.

Tags
throws
RuntimeException

setVolume()

Sets the volume.

public setVolume(int $volume) : void
Parameters
$volume : int

The volume to set.

Tags
throws
DomainException
throws
RuntimeException

start()

Starts the voice client.

public start() : void|bool
Return values
void|bool

stop()

Stops the current sound.

public stop() : void
Tags
throws
RuntimeException

switchChannel()

Switches voice channels.

public switchChannel(Channel $channel) : void
Parameters
$channel : Channel

The channel to switch to.

Tags
throws
InvalidArgumentException

unpause()

Unpauses the current sound.

public unpause() : void
Tags
throws
RuntimeException

checkForExecutable()

Checks if an executable exists on the system.

protected static checkForExecutable(string $executable) : string|null
Parameters
$executable : string
Return values
string|null

checkForFFmpeg()

Checks if FFmpeg is installed.

protected checkForFFmpeg() : bool
Return values
bool

Whether FFmpeg is installed or not.

checkForLibsodium()

Checks if libsodium-php is installed.

protected checkForLibsodium() : bool
Return values
bool

decodeUDP()

Decodes a UDP message to extract the IP address and port, then selects the protocol for voice communication.

protected decodeUDP(mixed $message) : void
Parameters
$message : mixed

The raw UDP message received from the server.

generateCommit()

protected generateCommit() : mixed

generateKeyPackage()

protected generateKeyPackage() : mixed

generateWelcome()

protected generateWelcome() : mixed

handleAudioData()

Handles raw opus data from the UDP server.

protected handleAudioData(string $message) : void
Parameters
$message : string

The data from the UDP server.

handleClientConnect()

Handles the event when a client connects to the voice server.

protected handleClientConnect(Payload $data) : void
Parameters
$data : Payload
Tags
since
10.19.0

handleClientDisconnect()

Handles the event when a client disconnects from the voice server.

protected handleClientDisconnect(Payload $data) : void
Parameters
$data : Payload
Tags
since
10.19.0

handleDaveExecuteTransition()

protected handleDaveExecuteTransition(mixed $data) : void
Parameters
$data : mixed

handleDaveMlsAnnounceCommitTransition()

protected handleDaveMlsAnnounceCommitTransition(mixed $data) : void
Parameters
$data : mixed

handleDaveMlsCommitWelcome()

protected handleDaveMlsCommitWelcome(mixed $data) : void
Parameters
$data : mixed

handleDaveMlsExternalSender()

protected handleDaveMlsExternalSender(mixed $data) : mixed
Parameters
$data : mixed

handleDaveMlsInvalidCommitWelcome()

protected handleDaveMlsInvalidCommitWelcome(mixed $data) : void
Parameters
$data : mixed

handleDaveMlsKeyPackage()

protected handleDaveMlsKeyPackage(mixed $data) : void
Parameters
$data : mixed

handleDaveMlsProposals()

protected handleDaveMlsProposals(mixed $data) : void
Parameters
$data : mixed

handleDaveMlsWelcome()

protected handleDaveMlsWelcome(mixed $data) : void
Parameters
$data : mixed

handleDavePrepareEpoch()

protected handleDavePrepareEpoch(mixed $data) : void
Parameters
$data : mixed

handleDavePrepareTransition()

protected handleDavePrepareTransition(mixed $data) : void
Parameters
$data : mixed

handleDaveTransitionReady()

protected handleDaveTransitionReady(mixed $data) : void
Parameters
$data : mixed

handleHello()

Handles the "Hello" event from the Discord voice server.

protected handleHello(Payload $data) : void
Parameters
$data : Payload
Tags
since
10.19.0

handleReady()

Handles the "ready" event for the voice client, initializing UDP connection and heartbeat.

protected handleReady(Payload $data) : void
Parameters
$data : Payload

The data object containing voice server connection details:

  • $data->d->ssrc: The synchronization source identifier.
  • $data->d->ip: The IP address for the UDP connection.
  • $data->d->port: The port for the UDP connection.
  • $data->d->modes: Supported encryption modes.
Tags
since
10.19.0

handleResumed()

Handles the 'resumed' event for the voice client.

protected handleResumed(Payload $data) : void
Parameters
$data : Payload

Data associated with the resumed event.

handleSessionDescription()

Handles the session description packet received from the Discord voice server.

protected handleSessionDescription(Payload $data) : void
Parameters
$data : Payload
Tags
since
10.19.0

handleSpeaking()

Handles the speaking state of a user.

protected handleSpeaking(Payload $data) : void
Parameters
$data : Payload

The data object received from the WebSocket.

heartbeatAck()

Handles the heartbeat acknowledgement from the voice WebSocket connection.

protected heartbeatAck(Payload $data) : void
Parameters
$data : Payload
Tags
since
10.19.0

mainSend()

Sends a message to the main websocket.

protected mainSend(Payload $data) : void
Parameters
$data : Payload

The data to send to the main WebSocket.

reset()

Resets the voice client.

protected reset() : void

resume()

Resumes a previously established voice connection.

protected resume() : void
Tags
since
10.19.0

selectProtocol()

Selects the UDP protocol for the voice connection and sends the selection payload.

protected selectProtocol(string $ip, int $port) : void
Parameters
$ip : string

The IP address to use for the voice connection.

$port : int

The port number to use for the voice connection.

Tags
since
10.19.0

send()

Sends a message to the voice websocket.

protected send(Payload|array<string|int, mixed> $data) : void
Parameters
$data : Payload|array<string|int, mixed>

The data to send to the voice WebSocket.

sendBuffer()

Sends a buffer to the UDP socket.

protected sendBuffer(string $data) : void
Parameters
$data : string

The data to send to the UDP server.


        
On this page

Search results