Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit facc5d2

Browse files
authored
Fix transport clean issue (#715)
1 parent 5dc3063 commit facc5d2

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

source/agent/conference/rtcController.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -315,46 +315,51 @@ class RtcController extends EventEmitter {
315315
terminateByOwner(ownerId) {
316316
log.debug(`terminateByOwner ${ownerId}`);
317317
const terminations = [];
318-
// Or just destroy the transport
318+
const transports = new Set();
319319
this.operations.forEach((operation, operationId) => {
320320
const transport = this.transports.get(operation.transportId);
321321
if (transport.owner === ownerId) {
322322
const p = this.terminate(operationId, operation.direction, 'Owner leave');
323323
terminations.push(p);
324+
transports.add(transport.id);
324325
}
325326
});
326-
return Promise.all(terminations);
327+
return Promise.all(terminations).then(() => {
328+
transports.forEach((transportId) => {
329+
const status = {type: 'failed', reason: 'Owner leave'};
330+
this.onTransportProgress(transportId, status);
331+
});
332+
});
327333
};
328334

329335
terminateByLocality(type, id) {
330336
log.debug(`terminateByLocality ${type} ${id}`);
331337
const terminations = [];
332-
// Or just destroy the transport
338+
const transports = new Set();
333339
this.operations.forEach((operation, operationId) => {
334340
const l = this.transports.get(operation.transportId).locality;
335-
if (l) {
336-
if ((type === 'worker' && l.agent === id) ||
337-
(type === 'node' && l.node === id)) {
338-
const p = this.terminate(operationId, operation.direction, 'Node lost');
339-
terminations.push(p);
340-
}
341+
if (l && ((type === 'worker' && l.agent === id) ||
342+
(type === 'node' && l.node === id))) {
343+
const p = this.terminate(operationId, operation.direction, 'Node lost');
344+
terminations.push(p);
345+
transports.add(operation.transportId);
341346
}
342347
});
343-
return Promise.all(terminations);
348+
return Promise.all(terminations).then(() => {
349+
transports.forEach((transportId) => {
350+
const status = {type: 'failed', reason: 'Owner leave'};
351+
this.onTransportProgress(transportId, status);
352+
});
353+
});
344354
};
345355

346-
onFaultDetected(type, id) {
347-
348-
}
349-
350356
destroy() {
351357
log.debug(`destroy`);
352-
const terminations = [];
353358
// Destroy all transports
354359
this.transports.forEach((transport, transportId) => {
355-
const p = this.rpcReq.destroyTransport(transportId);
360+
const status = {type: 'failed', reason: 'Owner leave'};
361+
this.onTransportProgress(transportId, status);
356362
});
357-
return Promise.all(terminations);
358363
};
359364

360365
setMute(sessionId, tracks, muted) {

0 commit comments

Comments
 (0)