fixed clean dualEp for rest dial dual_stream=true (#468)

* fixed clean dualEp for rest dial dual_stream=true

* fix

* fix

* fix

* fix

* fix
This commit is contained in:
Hoan Luu Huu
2023-09-22 19:12:34 +07:00
committed by GitHub
parent 991fff3386
commit 4e916acf6c
2 changed files with 8 additions and 5 deletions

View File

@@ -134,9 +134,6 @@ router.post('/', async(req, res) => {
if (req.body.dual_streams) {
dualEp = await ms.createEndpoint();
localSdp = mergeSdpMedia(localSdp, dualEp.local.sdp);
ep.on('destroy', () => {
dualEp.destroy();
});
}
const connectStream = async(remoteSdp) => {
@@ -145,7 +142,8 @@ router.post('/', async(req, res) => {
if (req.body.dual_streams) {
const [sdpLegA, sdpLebB] = extractSdpMedia(remoteSdp);
await Promise.all([ep.modify(sdpLegA), dualEp.modify(sdpLebB)]);
await ep.modify(sdpLegA);
await dualEp.modify(sdpLebB);
await ep.bridge(dualEp);
} else {
ep.modify(sdp);
@@ -243,6 +241,7 @@ router.post('/', async(req, res) => {
srf,
req: inviteReq,
ep,
ep2: dualEp,
tasks,
callInfo,
accountInfo,
@@ -295,6 +294,9 @@ router.post('/', async(req, res) => {
else console.error(err);
}
ep.destroy();
if (dualEp) {
dualEp.destroy();
}
setTimeout(restDial.kill.bind(restDial, cs), 5000);
}
} catch (err) {