Skip to content

Commit

Permalink
Attempt to fix session not found errors when node reconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Feb 8, 2024
1 parent e78c5bc commit 8e3b493
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/main/kotlin/dev/arbjerg/lavalink/internal/LavalinkSocket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ class LavalinkSocket(private val node: LavalinkNode) : WebSocketListener(), Clos
node.available = true
open = true
reconnectsAttempted = 0

node.playerCache.values.forEach { player ->
// Re-create the player on the node.
player.stateToBuilder()
.setNoReplace(false)
.subscribe()
}
}

override fun onMessage(webSocket: WebSocket, text: String) {
Expand All @@ -60,6 +53,13 @@ class LavalinkSocket(private val node: LavalinkNode) : WebSocketListener(), Clos
val sessionId = (event as Message.ReadyEvent).sessionId
node.sessionId = sessionId
logger.info("${node.name} is ready with session id $sessionId")

node.playerCache.values.forEach { player ->
// Re-create the player on the node.
player.stateToBuilder()
.setNoReplace(false)
.subscribe()
}
}

Message.Op.Stats -> {
Expand Down
2 changes: 1 addition & 1 deletion testbot/src/main/java/me/duncte123/testbot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static void registerLavalinkNodes(LavalinkClient client) {
URI.create("ws://localhost:2333"),
"youshallnotpass",
RegionGroup.EUROPE
),*/
)*/

client.addNode(
"Pi-local",
Expand Down

0 comments on commit 8e3b493

Please sign in to comment.