public interface ConnectionListener
Modifier and Type | Method | Description |
---|---|---|
void |
onPing(long ping) |
Called when JDA send a heartbeat packet to Discord and Discord sends an acknowledgement.
|
void |
onStatusChange(ConnectionStatus status) |
Called when the status of the audio channel changes.
|
void |
onUserSpeaking(User user,
boolean speaking) |
This method is an easy way to detect if a user is talking.
|
default void |
onUserSpeaking(User user,
boolean speaking,
boolean soundshare) |
This method is an easy way to detect if a user is talking.
|
default void |
onUserSpeaking(User user,
java.util.EnumSet<SpeakingMode> modes) |
This method is an easy way to detect if a user is talking.
|
void onPing(long ping)
ping
- The time, in milliseconds, for round-trip packet travel to discord.void onStatusChange(ConnectionStatus status)
status
- The new ConnectionStatus
of the audio connection.void onUserSpeaking(User user, boolean speaking)
Unlike the AudioReceiveHandler.handleCombinedAudio(CombinedAudio)
and
AudioReceiveHandler.handleUserAudio(UserAudio)
methods which are
fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such
is only fired when that changes. So while the AudioReceiveHandler.handleUserAudio(UserAudio)
method is fired every time JDA receives audio data from Discord,
this is only fired when that stream starts and when it stops.
If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning
and once after 3 minutes when they stop talking even though the AudioReceiveHandler.handleUserAudio(UserAudio)
method was fired thousands of times over the course of the 3 minutes.
user
- Never-null User
who's talking status has changed.speaking
- If true, the user has begun transmitting audio.default void onUserSpeaking(User user, java.util.EnumSet<SpeakingMode> modes)
Unlike the AudioReceiveHandler.handleCombinedAudio(CombinedAudio)
and
AudioReceiveHandler.handleUserAudio(UserAudio)
methods which are
fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such
is only fired when that changes. So while the AudioReceiveHandler.handleUserAudio(UserAudio)
method is fired every time JDA receives audio data from Discord,
this is only fired when that stream starts and when it stops.
If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning
and once after 3 minutes when they stop talking even though the AudioReceiveHandler.handleUserAudio(UserAudio)
method was fired thousands of times over the course of the 3 minutes.
user
- Never-null User
who's talking status has changed.modes
- EnumSet, containing the active speaking modes.
Empty if the user has stopped transmitting audio.EnumSet
,
SpeakingMode
default void onUserSpeaking(User user, boolean speaking, boolean soundshare)
Unlike the AudioReceiveHandler.handleCombinedAudio(CombinedAudio)
and
AudioReceiveHandler.handleUserAudio(UserAudio)
methods which are
fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such
is only fired when that changes. So while the AudioReceiveHandler.handleUserAudio(UserAudio)
method is fired every time JDA receives audio data from Discord,
this is only fired when that stream starts and when it stops.
If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning
and once after 3 minutes when they stop talking even though the AudioReceiveHandler.handleUserAudio(UserAudio)
method was fired thousands of times over the course of the 3 minutes.
user
- Never-null User
who's talking status has changed.speaking
- If true, the user has begun transmitting audio.soundshare
- If true, the user is using soundshare