bwmarrin / dgvoice

Discordgo Voice - A sub project to work on voice implementation for Discordgo
BSD 3-Clause "New" or "Revised" License
102 stars 39 forks source link

allow false over stop channel to continue #16

Closed korvyr closed 3 years ago

korvyr commented 6 years ago

This is running quite well on my own project.

It lets one send false to the stop channel to see if a stream is currently running without killing it, while still being able to send true to the stop channel to kill it:

select {
  stop <- false:
    // is alive, didn't kill
    // queue playback
  default:
    // is dead
    // start playback
}

and

select {
  stop <- true:
    // was alive, killed
    // start playback
  default:
    // is dead
    // start playback
}

This is very useful if you want to create a queue or the like and not override a current stream with new requests.

If anyone is interested in a full working queue using this, ping me and I can send you some snippets. My example is too integrated in my own project to copy/paste alone.

bwmarrin commented 3 years ago

This repo is only meant to be an introductory example on how to do this. I don't want to add or change any features or how it works. I'd recommend making a fork or your own version of this code and then applying this to that for your use.