Class AudioConnectionImpl

    • Constructor Detail

      • AudioConnectionImpl

        public AudioConnectionImpl​(ServerVoiceChannel channel,
                                   java.util.concurrent.CompletableFuture<AudioConnection> readyFuture,
                                   boolean muted,
                                   boolean deafened)
        Creates a new audio connection.
        Parameters:
        channel - The channel of the audio connection.
        readyFuture - An uncompleted future that gets completed when the connection is fully established.
        muted - Whether to connect self-muted.
        deafened - Whether to connect self-deafened.
    • Method Detail

      • getReadyFuture

        public java.util.concurrent.CompletableFuture<AudioConnection> getReadyFuture()
        Gets a future that finishes once the connection is fully established.
        Returns:
        The future.
      • getDisconnectFuture

        public java.util.concurrent.CompletableFuture<java.lang.Void> getDisconnectFuture()
        Gets a future that finishes once the connection has been disconnected.
        Returns:
        The future.
      • getSessionId

        public java.lang.String getSessionId()
        Gets the session id of the audio connection.
        Returns:
        The session id of the audio connection.
      • getToken

        public java.lang.String getToken()
        Gets the token for the audio connection.
        Returns:
        The token for the audio connection.
      • getEndpoint

        public java.lang.String getEndpoint()
        Gets the endpoint for the audio websocket.
        Returns:
        The endpoint for the audio websocket.
      • setChannel

        public void setChannel​(ServerVoiceChannel channel)
        Sets the channel of the connection.
        Parameters:
        channel - The channel of the connection.
      • setSessionId

        public void setSessionId​(java.lang.String sessionId)
        Sets the session id of the connection.
        Parameters:
        sessionId - The session id of the connection.
      • setToken

        public void setToken​(java.lang.String token)
        Sets the token for the audio connection.
        Parameters:
        token - The token for the audio connection.
      • setEndpoint

        public void setEndpoint​(java.lang.String endpoint)
        Sets the endpoint for the audio websocket.
        Parameters:
        endpoint - The endpoint for the audio websocket.
      • setSpeaking

        public void setSpeaking​(boolean speaking)
        Sets the current speaking mode.
        Parameters:
        speaking - The speaking mode to set
      • isPrioritySpeaking

        public boolean isPrioritySpeaking()
        Gets whether the connection is currently speaking with priority.
        Specified by:
        isPrioritySpeaking in interface AudioConnection
        Returns:
        Whether the connection is currently speaking with priority.
      • setPrioritySpeaking

        public void setPrioritySpeaking​(boolean prioritySpeaking)
        Sets whether the connection is priority speaking.
        Specified by:
        setPrioritySpeaking in interface AudioConnection
        Parameters:
        prioritySpeaking - Whether to speak with priority.
      • getSpeakingFlags

        public java.util.Set<SpeakingFlag> getSpeakingFlags()
        Gets the current set of active speaking flags.
        Specified by:
        getSpeakingFlags in interface AudioConnection
        Returns:
        The current set of active speaking flags.
      • setSpeakingFlags

        public void setSpeakingFlags​(java.util.EnumSet<SpeakingFlag> speakingFlags)
        Sets the current speaking flags and sends a speaking packet if they have changed.
        Parameters:
        speakingFlags - The new speaking flags to set.
      • tryConnect

        public boolean tryConnect()
        Tries to establish a connection if all required information is available and there's not already a connection.
        Returns:
        Whether it will try to connect or not.
      • reconnect

        public void reconnect()
        Performs a full reconnect of the audio connection by sending a new voice state update.
      • getCurrentAudioSourceBlocking

        public AudioSource getCurrentAudioSourceBlocking()
                                                  throws java.lang.InterruptedException
        Gets the current audio source, blocking the thread until it is available.
        Returns:
        The current audio source.
        Throws:
        java.lang.InterruptedException - If interrupted while waiting.
      • getCurrentAudioSourceBlocking

        public AudioSource getCurrentAudioSourceBlocking​(long timeout,
                                                         java.util.concurrent.TimeUnit unit)
                                                  throws java.lang.InterruptedException
        Gets the current audio source, waiting up to the specified wait time if necessary for an audio source to become available.
        Parameters:
        timeout - How long to wait before giving up.
        unit - A TimeUnit determining how to interpret the timeout parameter.
        Returns:
        The current audio source, or null if the specified waiting time elapsed.
        Throws:
        java.lang.InterruptedException - If interrupted while waiting.
      • moveTo

        public java.util.concurrent.CompletableFuture<java.lang.Void> moveTo​(ServerVoiceChannel destChannel,
                                                                             boolean selfMute,
                                                                             boolean selfDeafen)
        Specified by:
        moveTo in interface AudioConnection
      • close

        public java.util.concurrent.CompletableFuture<java.lang.Void> close()
        Specified by:
        close in interface AudioConnection
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object