_events and how to clear them?

Looking to properly dispose of transports, producers, consumers and that over the pipe-transport but not the connection of the pipe.

When I get a signal to close “producer” I loop through my map of the producers and the router’s map and delete the IDs. I then loop through my map of transports and the routers map and close then delete IDs. Beyond this, everything is working great unless there’s a better way?

Beyond that though I’m noticing when I log my Worker’s Router, I notice under _channel._events it’s not clearing and it’s stacking up.

Is there something I’m missing,

  1. Delete our references of any transport/producers/consumers
  2. Close (if not possible delete its mapped ID from Worker’s Router)

I was lazy when addressing this, but to give those an idea of how to properly clear, my createWebRtcTransport on both producer server and consumer have a DTLSState check, upon a fail/close I let its opposing end know that a request to stop is made with consumer/producer ids available.

If consumer servers get a close broadcast request we locate each consumer with respective ID and close it, we do additional tidying up by removing any left overs from our app or left over in the router or pipetransport.

If producer server gets a close viewer it’ll only react with a regular transport close however if it’s determined no other viewers on that server for the broadcast we signal the producer server to close the consumer. Because streams can turn on/off, we manually clear audio/video step by step.

If done right, consumer/producer server should return to 0% usage when not used even with a pipetransport activated, if done wrong you will see consumers stack across the pipe and lag multiple servers in good time. :slight_smile:

Fun little signaling project.