Hi there,
I am using router.pipeToRouter()
to copy a producer from one router to another, and having some difficultly understanding what the events refer in the context of a pipeConsumer. I am trying to ensure that I am reading the documentation correctly and handling all of the events appropriately.
I am creating the pipeConsumer and pipeProducer as follows:
// pipeConsumer is in the origin router
// pipeProducer is in the target router
const { pipeConsumer, pipeProducer } = await originRouter.pipeToRouter({
producerId: originalProducer.id,
router: targetRouter,
});
Is my understanding of what the pipeConsumer events refer to (and what an appropriate response would be) correct in the following snippet?
pipeConsumer.on("transportclose", () => {
// event: the pipeTransport between this pipeConsumer and its corresponding pipeProducer has closed
// action: close both accordingly
});
pipeConsumer.on("producerclose", () => {
// event: the originalProducer has closed
// action: close both this pipeConsumer and the corresponding pipeProducer
});
pipeConsumer.on("producerpause", () => {
// event: the originalProducer has paused
// action: pause the pipeProducer
});
pipeConsumer.on("producerresume", () => {
// event: the originalProducer has resumed
// action: resume the pipeProducer
});
My confusion stems from the fact that ‘transportclose’ seems like it could refer to either the underlying pipeTransport between the pipeConsumer and pipeProducer or the originalProducer’s transport having closed.
Thanks for your time!