How do i close a receiver subscription (opus stream)

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?
14 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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
C⁶H¹²O⁶
C⁶H¹²O⁶OP8mo ago
uhhh, can someone help here?? I had logged opusstream.closed and it was false on what? the receiver? the receiver haves no method called destroy
duck
duck8mo ago
on the opus stream itself
C⁶H¹²O⁶
C⁶H¹²O⁶OP8mo ago
ok let me just try it doesnt show errors but i want to make sure of something how do i check if it was destroyed
duck
duck8mo ago
<Readable>.destroyed exists
C⁶H¹²O⁶
C⁶H¹²O⁶OP8mo ago
ohk, thanks alot must i await destroy() ? coz .destroyed is false
duck
duck8mo ago
no, it's synchronous just to confirm before addressing this, could you share your updated code?
C⁶H¹²O⁶
C⁶H¹²O⁶OP8mo ago
yes just a second
stopListining(after = 0) {
setTimeout(() => this.opusStream.destroy(), after);
this.emit('stop-listining-stream');
console.log(this.opusStream.destroyed);
return this;
}
stopListining(after = 0) {
setTimeout(() => this.opusStream.destroy(), after);
this.emit('stop-listining-stream');
console.log(this.opusStream.destroyed);
return this;
}
its a class Player
duck
duck8mo ago
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
C⁶H¹²O⁶
C⁶H¹²O⁶OP8mo ago
the timeout is 0 just a second let me put those in the same func oh, yeah it is destroyed 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?
duck
duck8mo ago
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, #other-js-ts sounds like the channel for you
C⁶H¹²O⁶
C⁶H¹²O⁶OP8mo ago
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?
duck
duck8mo ago
I don't really use mongo, no I'd definitely recommend posting in #other-js-ts
C⁶H¹²O⁶
C⁶H¹²O⁶OP8mo ago
ok thanks alot
Want results from more Discord servers?
Add your server