In my ARI application, I set up listeners on a recording for RecordingStarted
, RecordingFinished
, and RecordingFailed
, and then start recording a bridge.
When either RecordingFinished
or RecordingFailed
is fired, or if the request to start recording the bridge fails, I want to clean up all the listeners I set up.
However, if the bridge is destroyed around the same time as setting up this recording, I get different behaviour depending on the exact timing:
- No
RecordingStarted
orRecordingFinished
event at all, even though the request to start recording the bridge succeeds - Just a
RecordingStarted
event, but noRecordingFinished
event - A
RecordingStarted
event followed by aRecordingFinished
event (good)
In the first two cases, I don’t know when to clean up the listeners on the recording - in the first case there is no event at all, and in the second case I can’t tell this apart from a situation where the recording has actually started and I obviously don’t want to clean up the listeners.
Has anyone else dealt with a similar issue or have any pointers?