#How do i close a receiver subscription (opus stream)

38 messages · Page 1 of 1 (latest)

slow juniper
#

setTimeout(() => this.connection.destroy(), after);
this.emit('stop-listining-stream');
console.log(this.opusStream);
return this;

i have this code, this code must destroy the connection, but even if the connetion gets destroyed, the receiver subscribtion doesnt end ever, so how do i end it?

nocturne kayakBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by staff
slow juniper
#

uhhh, can someone help here??

tepid coral
#

Destroying the connection should end all VoiceReceiverStreams of that connection Thonk

#

But you can always call .destroy() on it manually if not

slow juniper
slow juniper
unreal ferry
#

on the opus stream itself

slow juniper
#

let me just try

slow juniper
#

but i want to make sure of something

#

how do i check if it was destroyed

unreal ferry
#

<Readable>.destroyed exists

slow juniper
#

ohk, thanks alot

slow juniper
#

coz .destroyed is false

unreal ferry
#

no, it's synchronous
just to confirm before addressing this, could you share your updated code?

slow juniper
#

just a second

#
    setTimeout(() => this.opusStream.destroy(), after);
    this.emit('stop-listining-stream');
    console.log(this.opusStream.destroyed);
    return this;
}```
#

its a class Player

unreal ferry
#

you're checking immediately after setting the timeout, not when the timeout actually times out

#

I imagine this was also the case for previously when you were checking closed

slow juniper
#

the timeout is 0

#

just a second

#

let me put those in the same func

slow juniper
#

also wait i need your help please quickly with something else, not really djs related

#

but no one answers in all the servers

#

can you help?

unreal ferry
#

I don't know how I can answer whether I can help if I don't know what you need help with, but if it's not really djs related, #1081585952654360687 sounds like the channel for you

slow juniper
#

its a streams thing

#

createListeningStream(usersIds, writeStream, end) {
const receiver = this.connection.receiver;
this.opusStream = [];

usersIds.forEach((userId) => {
  const opusStream = receiver.subscribe(userId, {
    end: EndBehaviorType.Manual,
  });

  const opusDecoder = new prism.opus.Decoder({
    frameSize: 960,
    channels: 2,
    rate: 48000,
  });
  this.opusStream = opusStream;

  opusStream.pipe(opusDecoder).pipe(writeStream);
});
this.emit('create-listining-stream');
return this;

}

Simply the opus stream gets destroyed

#

but the writestream is gridfsbucket for mongodb is not getting saved in collection.files, but chunks get saved at collection.chunks

#

do you have any idea?

unreal ferry
#

I don't really use mongo, no
I'd definitely recommend posting in #1081585952654360687

slow juniper
#

ok