Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is #59 but i kind of squashed all the commits.
Added New attributes
Websocket.resume_session
: boolWebsocket.resume_timeout
: floatWebsocket.resume_key
: Union[str,wavelink.websocket._Key
, object] (Best left None)Websocket.payload_timeout
: float This is basically how recent requests shall be sent to the serverWebsocket.reset()
method.Websocket.close()
method.Node.heartbeat
: floatwavelink.errors.NodeSessionClosedError
: This error is handled within wavelink, but a warning message is logged for nowWebsocket._send_queue
method: called on connect if session is resumedWebsocket._can_resume
: wether resuming is enabled and configured.Websocket._queue
: Present only isWebsocket.resume_session
isTrue
wavelink.websocket._TimedQueue
: Anasyncio.Queue
subclass, which stores data only for a certain amount of timewavelink.websocket._Key
: The default key, this generates secure passwords, any other classes must be similar in functionalityNode
Attributes: pass the arguments toNode.connect
method.Node._resume_session
Node._resume_timeout
Node._payload_timeout
Node._resume_key
Example
Basic
Complete
Key.py
music_cog.py
New features proposed in this PR
Resuming
When the bot disconnects from the node (eg: 1006) then the lavalink server keeps on playing the music until session timeout, this allows the bot to reconnect and take control of the session. This PR implements this lavalink feature.
Key protocol
The key must be an
object
instance or astr
. The__repr__
method should return a new key. The__str__
method must return the last key that was generated by__repr__
. This protocol only defines these two methods since it needs to maintain compatibilty withstr
.Queueing
After the Node disconnects, we try to reconnect multiple times with a capped backoff before timeout. during this time the requests to the node are queued in an
asyncio.Queue
subclass whose payload expires after some time.This could be useful when you have an high timeout but want to only send recent requests.
Semver
This is a minor change. The changes are not breaking, assuming no-one initializes Node instances directly.