stop LavaplayerHandler actor when associated player is destroyed #27
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.
Existing Behavior
When
MusicManagerconnects to a channel, it updates its own map ofGuildIdto(AudioPlayer, ActorRef[LavaplayerHandler.Command])with the new guild. When aDisconnectFromChannelcommand is sent the reference is removed from the players map in all cases (whether or not the player is destroyed) and the actor is left alive. WhenConnectToChannelis called for a second time for the sameGuildId, there's no reference to the player/actor in the map and it attempts to create a new actor with the same guild id which leads akka to throw an exception for a non-unique name.New Behavior
On disconnect if
destroyPlayeris set totrue, the associated actor is also shutdown and the reference in the players map is removed. In all other cases the behavior is kept the same and theLavaplayerHandleractor is left running.