[mirotalksfu] - refactoring
هذا الالتزام موجود في:
@@ -71,6 +71,10 @@ module.exports = class Peer {
|
||||
// TRANSPORT
|
||||
// ####################################################
|
||||
|
||||
getTransports() {
|
||||
return JSON.parse(JSON.stringify([...this.transports]));
|
||||
}
|
||||
|
||||
addTransport(transport) {
|
||||
this.transports.set(transport.id, transport);
|
||||
}
|
||||
@@ -95,6 +99,10 @@ module.exports = class Peer {
|
||||
// PRODUCER
|
||||
// ####################################################
|
||||
|
||||
getProducers() {
|
||||
return JSON.parse(JSON.stringify([...this.producers]));
|
||||
}
|
||||
|
||||
getProducer(producer_id) {
|
||||
return this.producers.get(producer_id);
|
||||
}
|
||||
@@ -161,12 +169,17 @@ module.exports = class Peer {
|
||||
log.warn('Close Producer', error.message);
|
||||
}
|
||||
this.producers.delete(producer_id);
|
||||
log.debug('Producer closed and deleted', { producer_id });
|
||||
}
|
||||
|
||||
// ####################################################
|
||||
// CONSUMER
|
||||
// ####################################################
|
||||
|
||||
getConsumers() {
|
||||
return JSON.parse(JSON.stringify([...this.consumers]));
|
||||
}
|
||||
|
||||
async createConsumer(consumer_transport_id, producer_id, rtpCapabilities) {
|
||||
try {
|
||||
const consumerTransport = this.transports.get(consumer_transport_id);
|
||||
@@ -234,7 +247,13 @@ module.exports = class Peer {
|
||||
|
||||
removeConsumer(consumer_id) {
|
||||
if (this.consumers.has(consumer_id)) {
|
||||
try {
|
||||
this.consumers.get(consumer_id).close();
|
||||
} catch (error) {
|
||||
log.warn('Close Consumer', error.message);
|
||||
}
|
||||
this.consumers.delete(consumer_id);
|
||||
log.debug('Consumer closed and deleted', { consumer_id });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم