public class ListenerProxy extends java.lang.Object implements ConnectionListener
Constructor and Description |
---|
ListenerProxy() |
Modifier and Type | Method and Description |
---|---|
ConnectionListener |
getListener() |
void |
onPing(long ping) |
void |
onStatusChange(ConnectionStatus status) |
void |
onUserSpeaking(User user,
boolean speaking)
This method is an easy way to detect if a user is talking.
|
void |
setListener(ConnectionListener listener) |
public void onPing(long ping)
onPing
in interface ConnectionListener
public void onStatusChange(ConnectionStatus status)
onStatusChange
in interface ConnectionListener
public void onUserSpeaking(User user, boolean speaking)
ConnectionListener
Unlike the AudioReceiveHandler.handleCombinedAudio(net.dv8tion.jda.core.audio.CombinedAudio)
and AudioReceiveHandler.handleUserAudio(net.dv8tion.jda.core.audio.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(net.dv8tion.jda.core.audio.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(net.dv8tion.jda.core.audio.UserAudio)
method was fired thousands of times over the course of the 3 minutes.
onUserSpeaking
in interface ConnectionListener
user
- Never-null User
who's talking status has changed.speaking
- If true, the user has begun transmitting audio.public void setListener(ConnectionListener listener)
public ConnectionListener getListener()