Skip to content

Commit

Permalink
Merge pull request #1043 from lavalink-devs/dev
Browse files Browse the repository at this point in the history
release v4.0.5
  • Loading branch information
topi314 authored May 5, 2024
2 parents c3c9e25 + 0e13bbf commit 9b88fb9
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 15 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
Each release usually includes various fixes and improvements.
The most noteworthy of these, as well as any features and breaking changes, are listed here.

## v4.0.5
* Updated Lavaplayer to [`2.1.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.2)
* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track)
* Added option to enable [Nico](https://www.nicovideo.jp/) source
* Expose Lavalink sessions to plugins via the `ISocketServer` interface

> [!WARNING]
> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead.
## v4.0.4
* Update Lavaplayer to `2.1.1`
* Update Lavaplayer to [`2.1.1`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.1)

## v4.0.3
* Fixed plugins not registering (introduced in [`4.0.2`](https://github.com/lavalink-devs/Lavalink/releases/tag/4.0.2))
Expand Down Expand Up @@ -89,6 +98,18 @@ Contributors:

</details>

## v3.7.12
* Updated Lavaplayer to [`1.5.4`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.4)
* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track)

> [!WARNING]
> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead.
## v3.7.11
* Fixed not being able to seek when player is paused
* Update Oshi to `6.4.3`
* Update Lavaplayer to `1.5.3`

## v3.7.10
* Update lavaplayer to [`1.5.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.2) - Fixed NPE on missing author in playlist tracks in YouTube

Expand Down
3 changes: 2 additions & 1 deletion LavalinkServer/application.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ lavalink:
soundcloud: true
twitch: true
vimeo: true
http: true
nico: true
http: true # warning: keeping HTTP enabled without a proxy configured could expose your server's IP address.
local: false
filters: # All filters are enabled by default
volume: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.sedmelluq.discord.lavaplayer.source.AudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.bandcamp.BandcampAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.http.HttpAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.local.LocalAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.nico.NicoAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.soundcloud.*
import com.sedmelluq.discord.lavaplayer.source.twitch.TwitchStreamAudioSourceManager
import com.sedmelluq.discord.lavaplayer.source.vimeo.VimeoAudioSourceManager
Expand Down Expand Up @@ -102,6 +103,14 @@ class AudioPlayerConfiguration {
val mcr: MediaContainerRegistry = MediaContainerRegistry.extended(*mediaContainerProbes.toTypedArray())

if (sources.isYoutube) {
log.warn(
"""
The default Youtube source is now deprecated and won't receive further updates.
You should use the new Youtube source plugin instead.
https://github.com/lavalink-devs/youtube-source#plugin.
To disable this warning, set 'lavalink.server.sources.youtube' to false in your application.yml.
""".trimIndent()
)
val youtubeConfig = serverConfig.youtubeConfig
val youtube: YoutubeAudioSourceManager
if (youtubeConfig != null) {
Expand Down Expand Up @@ -155,6 +164,7 @@ class AudioPlayerConfiguration {
if (sources.isBandcamp) audioPlayerManager.registerSourceManager(BandcampAudioSourceManager())
if (sources.isTwitch) audioPlayerManager.registerSourceManager(TwitchStreamAudioSourceManager())
if (sources.isVimeo) audioPlayerManager.registerSourceManager(VimeoAudioSourceManager())
if (sources.isNico) audioPlayerManager.registerSourceManager(NicoAudioSourceManager())
if (sources.isLocal) audioPlayerManager.registerSourceManager(LocalAudioSourceManager(mcr))

audioSourceManagers.forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ data class AudioSourcesConfig(
var isSoundcloud: Boolean = true,
var isTwitch: Boolean = true,
var isVimeo: Boolean = true,
var isNico: Boolean = false,
var isHttp: Boolean = true,
var isLocal: Boolean = false,
)
17 changes: 9 additions & 8 deletions LavalinkServer/src/main/java/lavalink/server/io/SocketServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package lavalink.server.io

import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager
import dev.arbjerg.lavalink.api.AudioPluginInfoModifier
import dev.arbjerg.lavalink.api.ISocketServer
import dev.arbjerg.lavalink.api.PluginEventHandler
import dev.arbjerg.lavalink.protocol.v4.Message
import dev.arbjerg.lavalink.protocol.v4.PlayerState
Expand All @@ -46,11 +47,11 @@ final class SocketServer(
koeOptions: KoeOptions,
private val eventHandlers: List<PluginEventHandler>,
private val pluginInfoModifiers: List<AudioPluginInfoModifier>
) : TextWebSocketHandler() {
) : TextWebSocketHandler(), ISocketServer {

// sessionID <-> Session
val contextMap = ConcurrentHashMap<String, SocketContext>()
private val resumableSessions = mutableMapOf<String, SocketContext>()
override val sessions = ConcurrentHashMap<String, SocketContext>()
override val resumableSessions = mutableMapOf<String, SocketContext>()
private val koe = Koe.koe(koeOptions)
private val statsCollector = StatsCollector(this)
private val charPool = ('a'..'z') + ('0'..'9')
Expand Down Expand Up @@ -81,12 +82,12 @@ final class SocketServer(
var sessionId: String
do {
sessionId = List(16) { charPool.random() }.joinToString("")
} while (contextMap[sessionId] != null)
} while (sessions[sessionId] != null)
return sessionId
}

val contexts: Collection<SocketContext>
get() = contextMap.values
get() = sessions.values

@Suppress("UastIncorrectHttpHeaderInspection")
override fun afterConnectionEstablished(session: WebSocketSession) {
Expand All @@ -100,7 +101,7 @@ final class SocketServer(

if (resumable != null) {
session.attributes["sessionId"] = resumable.sessionId
contextMap[resumable.sessionId] = resumable
sessions[resumable.sessionId] = resumable
resumable.resume(session)
log.info("Resumed session with id $sessionId")
resumable.eventEmitter.onWebSocketOpen(true)
Expand All @@ -123,7 +124,7 @@ final class SocketServer(
eventHandlers,
pluginInfoModifiers
)
contextMap[sessionId] = socketContext
sessions[sessionId] = socketContext
socketContext.sendMessage(Message.Serializer, Message.ReadyEvent(false, sessionId))
socketContext.eventEmitter.onWebSocketOpen(false)
if (clientName != null) {
Expand All @@ -140,7 +141,7 @@ final class SocketServer(
}

override fun afterConnectionClosed(session: WebSocketSession, status: CloseStatus) {
val context = contextMap.remove(session.attributes["sessionId"]) ?: return
val context = sessions.remove(session.attributes["sessionId"]) ?: return
if (context.resumable) {
resumableSessions.remove(context.sessionId)?.let { removed ->
log.warn(
Expand Down
2 changes: 1 addition & 1 deletion LavalinkServer/src/main/java/lavalink/server/util/util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fun getRootCause(throwable: Throwable?): Throwable {
}

fun socketContext(socketServer: SocketServer, sessionId: String) =
socketServer.contextMap[sessionId] ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Session not found")
socketServer.sessions[sessionId] ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Session not found")

fun existingPlayer(socketContext: SocketContext, guildId: Long) =
socketContext.players[guildId] ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Player not found")
Expand Down
7 changes: 7 additions & 0 deletions docs/changelog/v3.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v3.7.12
* Updated Lavaplayer to [`1.5.4`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.4)
* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track)

> [!WARNING]
> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead.
## v3.7.11
* Fixed not being able to seek when player is paused
* Updated Oshi to `6.4.3`
Expand Down
11 changes: 10 additions & 1 deletion docs/changelog/v4.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## v4.0.5
* Updated Lavaplayer to [`2.1.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.2)
* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track)
* Added option to enable [Nico](https://www.nicovideo.jp/) source
* Expose Lavalink sessions to plugins via the `ISocketServer` interface

> [!WARNING]
> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead.
## v4.0.4
* Updated Lavaplayer to `2.1.1`
* Updated Lavaplayer to [`2.1.1`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.1)

## v4.0.3
* Fixed plugins not registering (introduced in [`4.0.2`](https://github.com/lavalink-devs/Lavalink/releases/tag/4.0.2))
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ LAVALINK_SERVER_SOURCES_SOUNDCLOUD
LAVALINK_SERVER_SOURCES_TWITCH
LAVALINK_SERVER_SOURCES_VIMEO
LAVALINK_SERVER_SOURCES_HTTP
LAVALINK_SERVER_SOURCES_NICO
LAVALINK_SERVER_SOURCES_LOCAL
LAVALINK_SERVER_FILTERS_VOLUME
Expand Down
17 changes: 17 additions & 0 deletions plugin-api/src/main/java/dev/arbjerg/lavalink/api/ISocketServer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dev.arbjerg.lavalink.api

/**
* Represents a Lavalink server which handles WebSocket connections.
*/
interface ISocketServer {
/**
* A map of all active sessions by their session id.
*/
val sessions: Map<String, ISocketContext>

/**
* A map of all resumable sessions by their session id.
* A session is resumable if the client configured resuming and has disconnected.
*/
val resumableSessions: Map<String, ISocketContext>
}
6 changes: 3 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ fun VersionCatalogBuilder.spring() {
}

fun VersionCatalogBuilder.voice() {
version("lavaplayer", "2.1.1")
version("lavaplayer", "2.1.2")

library("lavaplayer", "dev.arbjerg", "lavaplayer").versionRef("lavaplayer")
library("lavaplayer-ip-rotator", "dev.arbjerg", "lavaplayer-ext-youtube-rotator").versionRef("lavaplayer")
library("lavadsp", "dev.arbjerg", "lavadsp").version("0.7.8")

library("koe", "moe.kyokobot.koe", "core").version("2.0.0-rc2")
library("koe-udpqueue", "moe.kyokobot.koe", "ext-udpqueue").version("2.0.0-rc2")
library("koe", "moe.kyokobot.koe", "core").version("2.0.1")
library("koe-udpqueue", "moe.kyokobot.koe", "ext-udpqueue").version("2.0.1")

version("udpqueue", "0.2.7")
val platforms = listOf("linux-x86-64", "linux-x86", "linux-aarch64", "linux-arm", "linux-musl-x86-64", "linux-musl-aarch64", "win-x86-64", "win-x86", "darwin")
Expand Down

0 comments on commit 9b88fb9

Please sign in to comment.