Package moe.kyokobot.koe
Interface MediaConnection
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Subinterfaces:
MediaConnectionExperimental
- All Known Implementing Classes:
MediaConnectionImpl
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes and disposes this connection, cannot be used after this method is called.connect(VoiceServerInfo info) Connects to Discord voice server using specified info.voidStops polling media frames, disconnects from the gateway and cleans everything up.@Nullable AudioFrameProvider@NotNull KoeClient@Nullable MediaGatewayConnectionlong@NotNull KoeOptionsint@Nullable VoiceServerInfovoidvoidregisterListener(KoeEventListener listener) default voidsetAudioCodec(@NotNull CodecInfo info) Sets the audio codec using a codec info (convenience method).voidsetAudioCodec(@NotNull CodecInstance audioCodec) Sets the audio codec instance for this connection.voidsetAudioSender(@Nullable AudioFrameProvider sender) voidsetSpeakingMask(int mask) Sets speaking flags announced to the gateway when audio playback starts, seeSpeakingFlags.voidStarts polling audio frames.voidStops polling audio frames.voidunregisterListener(KoeEventListener listener) voidupdateSpeakingState(int mask) Sends speaking state notification to the gateway.
-
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
-
getOptions
-
getAudioSender
-
getGuildId
long getGuildId() -
getGatewayConnection
-
getVoiceServerInfo
-
getConnectionHandler
ConnectionHandler<?> getConnectionHandler() -
setAudioSender
-
setAudioCodec
Sets the audio codec instance for this connection.- Parameters:
audioCodec- the codec instance to use
-
setAudioCodec
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
-
unregisterListener
-
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, seeSpeakingFlags. If the connection is currently announced as speaking, the new flags are sent immediately. Defaults toSpeakingFlags.NORMAL.- Parameters:
mask- new speaking flags
-
close
void close()Closes and disposes this connection, cannot be used after this method is called.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-