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
- 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 staffuhhh, can someone help here??
I had logged opusstream.closed and it was false
on what? the receiver? the receiver haves no method called destroy
on the opus stream itself
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
<Readable>.destroyed
existsohk, thanks alot
must i await destroy() ?
coz .destroyed is false
no, it's synchronous
just to confirm before addressing this, could you share your updated code?
yes
just a second
its a class Player
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
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?
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
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?
I don't really use mongo, no
I'd definitely recommend posting in #other-js-ts
ok
thanks alot