Interface MediaConnection

All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
MediaConnectionExperimental
All Known Implementing Classes:
MediaConnectionImpl

@NonExtendable public interface MediaConnection extends Closeable
  • Method Details

    • connect

      Connects to Discord voice server using specified info.
      Parameters:
      info - Discord voice server connection information
      Returns:
      future which completes once Koe is connected to both voice gateway and can successfully send UDP packets, so you can send audio data.
    • disconnect

      void disconnect()
      Stops polling media frames, disconnects from the gateway and cleans everything up.
      See Also:
    • reconnect

      void reconnect()
    • getClient

      @NotNull @NotNull KoeClient getClient()
    • getOptions

      @NotNull @NotNull KoeOptions getOptions()
    • getAudioSender

      @Nullable @Nullable AudioFrameProvider getAudioSender()
    • getGuildId

      long getGuildId()
    • getGatewayConnection

      @Nullable @Nullable MediaGatewayConnection getGatewayConnection()
    • getVoiceServerInfo

      @Nullable @Nullable VoiceServerInfo getVoiceServerInfo()
    • getConnectionHandler

      ConnectionHandler<?> getConnectionHandler()
    • setAudioSender

      void setAudioSender(@Nullable @Nullable AudioFrameProvider sender)
    • setAudioCodec

      void setAudioCodec(@NotNull @NotNull CodecInstance audioCodec)
      Sets the audio codec instance for this connection.
      Parameters:
      audioCodec - the codec instance to use
    • setAudioCodec

      default void setAudioCodec(@NotNull @NotNull CodecInfo info)
      Sets the audio codec using a codec info (convenience method). Creates a codec instance with default payload types.
      Parameters:
      info - the codec info to use
    • startAudioFramePolling

      void startAudioFramePolling()
      Starts polling audio frames. Called automatically after connecting, you don't have to.
    • stopAudioFramePolling

      void stopAudioFramePolling()
      Stops polling audio frames.
      See Also:
    • registerListener

      void registerListener(KoeEventListener listener)
    • unregisterListener

      void unregisterListener(KoeEventListener listener)
    • updateSpeakingState

      void updateSpeakingState(int mask)
      Sends speaking state notification to the gateway.
      Parameters:
      mask - new speaking state
    • getSpeakingMask

      int getSpeakingMask()
      Returns:
      speaking flags announced to the gateway when audio playback starts, see SpeakingFlags.
    • setSpeakingMask

      void setSpeakingMask(int mask)
      Sets speaking flags announced to the gateway when audio playback starts, see SpeakingFlags. If the connection is currently announced as speaking, the new flags are sent immediately. Defaults to SpeakingFlags.NORMAL.
      Parameters:
      mask - new speaking flags
    • close

      void close()
      Closes and disposes this connection, cannot be used after this method is called.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable