Tomato6966 / lavalink-client

Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.
https://tomato6966.github.io/lavalink-client/
MIT License
62 stars 22 forks source link

[Question] How node player resume works #40

Closed EvilG-MC closed 4 months ago

EvilG-MC commented 4 months ago

What I mean is, when a node goes offline, all players go offline.

Then, the manager tries to reconnect to the node and the player plays again.

With shoukaku this is automatically, but in the case of lavalink-client, what would it be like? Because if you put the sessionId in the nodes array, in My case it didn't seem to work.

Tomato6966 commented 4 months ago

you need to call node.updateSession(true) in order to activate resuming. Then you can provide the sessionId in the node connect / create options, and it will resume, if connected during the duration. However you have to manually re-create the players and the queue on the client yourself. The queue can be stored externally and resynced via queue.utils.sync() On a resumed session nodeManager emits a "resumed" event.

aka See readme

Tomato6966 commented 4 months ago

https://github.com/Tomato6966/lavalink-client?tab=readme-ov-file#version-200

# Node Resuming got supported
# First enable it by doing: (It's now called updateSession)
+ await player.node.updateSession(true, 360_000);
# then when reconnecting to the node add to the node.createeOptions the sessionId: "" of the previous session
# and after  connecting the nodeManager.on("resumed", (node, payload, players) => {}) will be executed, where you can sync the players!

# Node Options got adjusted # It's a property not a method should be treated readonly
+ node.resuming: { enabled: boolean, timeout: number | null }; 
EvilG-MC commented 4 months ago

I see, thank you so much!