Package andesite.handler
Interface AndesiteRequestHandler
public interface AndesiteRequestHandler
-
Method Summary
Modifier and Type Method Description JsonObject
destroy(java.lang.String userId, java.lang.String guildId, boolean cleanup)
Handles a destroy request.JsonObject
filters(java.lang.String userId, java.lang.String guildId, JsonObject payload)
Handles a filters payload.java.util.Map<java.lang.String,MetadataEntry>
metadataFields(NamePartJoiner joiner)
Returns a map of the metadata fields to their values.JsonObject
mixer(java.lang.String userId, java.lang.String guildId, JsonObject payload)
Handles a mixer payload.JsonObject
nodeStats()
Returns the stats of the node.JsonObject
nodeStatsForLavalink()
Returns lavalink compatible stats of the node.JsonObject
pause(java.lang.String userId, java.lang.String guildId, JsonObject payload)
Handles a pause payload.JsonObject
play(java.lang.String userId, java.lang.String guildId, JsonObject payload)
Handles a play payload.JsonObject
player(java.lang.String userId, java.lang.String guildId)
Returns the encoded player, if it exists.void
provideVoiceServerUpdate(java.lang.String userId, JsonObject json)
Provides a voice server update.java.util.concurrent.CompletionStage<JsonObject>
resolveTracks(java.lang.String identifier)
Resolves tracks with the provided identifier.JsonObject
seek(java.lang.String userId, java.lang.String guildId, JsonObject payload)
Handles a seek payload.JsonObject
stop(java.lang.String userId, java.lang.String guildId)
Handles a stop request.void
subscribe(java.lang.String userId, java.lang.String guildId, java.lang.Object key, java.util.function.Consumer<JsonObject> eventSink)
Subscribes a provided sink to receive events for the player.JsonObject
update(java.lang.String userId, java.lang.String guildId, JsonObject payload)
Handles an update payload.JsonObject
volume(java.lang.String userId, java.lang.String guildId, JsonObject payload)
Handles a volume payload.
-
Method Details
-
metadataFields
@Nonnull @CheckReturnValue java.util.Map<java.lang.String,MetadataEntry> metadataFields(@Nonnull NamePartJoiner joiner)Returns a map of the metadata fields to their values. The keys will be formatted based on the providedNamePartJoiner
.- Parameters:
joiner
- Formatter for the map keys.- Returns:
- The metadata map.
-
provideVoiceServerUpdate
Provides a voice server update. The provided json object must be a valid voice update payload.- Parameters:
userId
- User id for the payload.json
- Voice update payload.
-
player
Returns the encoded player, if it exists.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.- Returns:
- The encoded player, or null if it doesn't exist.
-
subscribe
void subscribe(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull java.lang.Object key, @Nonnull java.util.function.Consumer<JsonObject> eventSink)Subscribes a provided sink to receive events for the player. The sink should forward the events to clients.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.key
- Unique key identifying this consumer. Anything works, as long as it's unique.eventSink
- Sink for events.
-
play
@Nonnull JsonObject play(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull JsonObject payload)Handles a play payload. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.payload
- Payload to handle.- Returns:
- The player state.
-
mixer
@Nonnull JsonObject mixer(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull JsonObject payload)Handles a mixer payload. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.payload
- Payload to handle.- Returns:
- The player state.
-
stop
Handles a stop request. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.- Returns:
- The player state.
-
pause
@Nonnull JsonObject pause(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull JsonObject payload)Handles a pause payload. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.payload
- Payload to handle.- Returns:
- The player state.
-
seek
@Nonnull JsonObject seek(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull JsonObject payload)Handles a seek payload. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.payload
- Payload to handle.- Returns:
- The player state.
-
volume
@Nonnull JsonObject volume(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull JsonObject payload)Handles a volume payload. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.payload
- Payload to handle.- Returns:
- The player state.
-
filters
@Nonnull JsonObject filters(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull JsonObject payload)Handles a filters payload. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.payload
- Payload to handle.- Returns:
- The player state.
-
update
@Nonnull JsonObject update(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, @Nonnull JsonObject payload)Handles an update payload. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.payload
- Payload to handle.- Returns:
- The player state.
-
destroy
@Nullable JsonObject destroy(@Nonnull java.lang.String userId, @Nonnull java.lang.String guildId, boolean cleanup)Handles a destroy request. Returns the player state.- Parameters:
userId
- User id of the player.guildId
- Guild id of the player.cleanup
- Whether or not this player is being destroyed by an automatic cleanup.- Returns:
- The player state, or null if it doesn't exist.
-
resolveTracks
@Nonnull @CheckReturnValue java.util.concurrent.CompletionStage<JsonObject> resolveTracks(@Nonnull java.lang.String identifier)Resolves tracks with the provided identifier.
If the identifier is a string, starts withytsearch:
orscsearch:
, it's used as-is for loading.
If it starts withraw:
, the first 4 characters (raw:) are removed and the rest is used for loading.
Otherwise, the identifier is prepended withytsearch:
and used for loading.- Parameters:
identifier
- Identifier to load.- Returns:
- The result of the track lookup.
-
nodeStats
Returns the stats of the node.- Returns:
- The stats of the node.
-
nodeStatsForLavalink
Returns lavalink compatible stats of the node.- Returns:
- Lavalink compatible stats of the node.
-