@NotThreadSafe
public interface IPacketProvider
IAudioSendSystem
and
JDA's internal audio system, providing access to audio packets built from data provided from
AudioSendHandlers
.
Note that this provider is not thread-safe!
Modifier and Type | Method | Description |
---|---|---|
VoiceChannel |
getConnectedChannel() |
Provides the current channel that this connection is transmitting to.
|
java.lang.String |
getIdentifier() |
Provides a unique String identifier for the connection.
|
java.net.DatagramPacket |
getNextPacket(boolean changeTalking) |
Used to retrieve an audio packet to send to Discord.
|
java.nio.ByteBuffer |
getNextPacketRaw(boolean changeTalking) |
Used to retrieve an audio packet to send to Discord.
|
java.net.InetSocketAddress |
getSocketAddress() |
The connected socket address for this audio connection.
|
java.net.DatagramSocket |
getUdpSocket() |
The UDP connection for this audio connection.
|
void |
onConnectionError(ConnectionStatus status) |
This method is used to indicate a connection error to JDA so that the connection can be properly shutdown.
|
void |
onConnectionLost() |
This method is used to indicate to JDA that the UDP connection has been lost, whether that be due internet loss
or some other unknown reason.
|
java.lang.String getIdentifier()
VoiceChannel getConnectedChannel()
VoiceChannel
that this connection is sending to.java.net.DatagramSocket getUdpSocket()
DefaultSendSystem
uses this socket to send audio packets to discord, and this is also the socket used to receive audio packets from discord.
java.net.InetSocketAddress getSocketAddress()
getNextPacket(boolean)
.InetSocketAddress
of the current UDP connectionjava.nio.ByteBuffer getNextPacketRaw(boolean changeTalking)
changeTalking
parameter is used
to control whether or not the talking indicator should be changed if the
AudioSendHandler
cannot provide an audio packet.
Use case for this parameter would be front-loading or queuing many audio packets ahead of send time, and if the AudioSendHandler
did not have enough to fill the entire queue, you would have changeTalking
set to false
until the queue
was empty. At that point, you would switch to true
when requesting a new packet due to the fact that if
one was not available, the developer would not have a packet to send, thus the logged in account is no longer "talking".
Note: When the AudioSendHandler cannot or does not provide a new packet to send, this method will return null.
The buffer used here may be used again on the next call to this getter, if you plan on storing the data copy it.
The buffer was created using ByteBuffer.allocate(int)
and is not direct.
changeTalking
- Whether or not to change the talking indicator if the AudioSendHandler cannot provide a new audio packet.ByteBuffer
containing an encoded and encrypted packet
of audio data ready to be sent to discord.java.net.DatagramPacket getNextPacket(boolean changeTalking)
changeTalking
parameter is used
to control whether or not the talking indicator should be changed if the
AudioSendHandler
cannot provide an audio packet.
Use case for this parameter would be front-loading or queuing many audio packets ahead of send time, and if the AudioSendHandler
did not have enough to fill the entire queue, you would have changeTalking
set to false
until the queue
was empty. At that point, you would switch to true
when requesting a new packet due to the fact that if
one was not available, the developer would not have a packet to send, thus the logged in account is no longer "talking".
Note: When the AudioSendHandler cannot or does not provide a new packet to send, this method will return null.
changeTalking
- Whether or not to change the talking indicator if the AudioSendHandler cannot provide a new audio packet.DatagramPacket
containing an encoded and encrypted packet
of audio data ready to be sent to discord.void onConnectionError(ConnectionStatus status)
status
- The ConnectionStatus
being reported to JDA
indicating an error with connection.void onConnectionLost()
onConnectionError(net.dv8tion.jda.core.audio.hooks.ConnectionStatus)
as it provides a default error
reason of ConnectionStatus.ERROR_LOST_CONNECTION
.