[mirotalksfu] - refactoring
هذا الالتزام موجود في:
@@ -76,11 +76,15 @@ module.exports = class Peer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connectTransport(transport_id, dtlsParameters) {
|
async connectTransport(transport_id, dtlsParameters) {
|
||||||
if (!this.transports.has(transport_id)) return;
|
if (!this.transports.has(transport_id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
await this.transports.get(transport_id).connect({
|
await this.transports.get(transport_id).connect({
|
||||||
dtlsParameters: dtlsParameters,
|
dtlsParameters: dtlsParameters,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ module.exports = class Room {
|
|||||||
const { maxIncomingBitrate, initialAvailableOutgoingBitrate, listenInfos } = this.webRtcTransport;
|
const { maxIncomingBitrate, initialAvailableOutgoingBitrate, listenInfos } = this.webRtcTransport;
|
||||||
|
|
||||||
const webRtcTransportOptions = {
|
const webRtcTransportOptions = {
|
||||||
...(this.webRtcServerActive ? { webRtcServer: this.webRtcServer } : { listenInfos }),
|
...(this.webRtcServerActive ? { webRtcServer: this.webRtcServer } : { listenInfos: listenInfos }),
|
||||||
enableUdp: true,
|
enableUdp: true,
|
||||||
enableTcp: true,
|
enableTcp: true,
|
||||||
preferUdp: true,
|
preferUdp: true,
|
||||||
@@ -319,7 +319,16 @@ module.exports = class Room {
|
|||||||
return this.printError(`[Room|connectPeerTransport] Peer with socket ID ${socket_id} not found`);
|
return this.printError(`[Room|connectPeerTransport] Peer with socket ID ${socket_id} not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.peers.get(socket_id).connectTransport(transport_id, dtlsParameters);
|
const peer = this.peers.get(socket_id);
|
||||||
|
|
||||||
|
const connectTransport = await peer.connectTransport(transport_id, dtlsParameters);
|
||||||
|
|
||||||
|
if (!connectTransport) {
|
||||||
|
return this.printError(
|
||||||
|
`[Room|connectPeerTransport] error: Transport with ID ${transport_id} not found`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return '[Room|connectPeerTransport] done';
|
return '[Room|connectPeerTransport] done';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error('Error connecting peer transport', error.message);
|
log.error('Error connecting peer transport', error.message);
|
||||||
@@ -427,7 +436,10 @@ module.exports = class Room {
|
|||||||
|
|
||||||
closeProducer(socket_id, producer_id) {
|
closeProducer(socket_id, producer_id) {
|
||||||
if (!socket_id || !producer_id || !this.peers.has(socket_id)) return;
|
if (!socket_id || !producer_id || !this.peers.has(socket_id)) return;
|
||||||
this.peers.get(socket_id).closeProducer(producer_id);
|
|
||||||
|
const peer = this.peers.get(socket_id);
|
||||||
|
|
||||||
|
peer.closeProducer(producer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|||||||
@@ -964,7 +964,9 @@ function startServer() {
|
|||||||
? is_presenter
|
? is_presenter
|
||||||
: await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
|
: await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
|
||||||
|
|
||||||
room.getPeers().get(socket.id).updatePeerInfo({ type: 'presenter', status: isPresenter });
|
const peer = room.getPeers().get(socket.id);
|
||||||
|
|
||||||
|
peer.updatePeerInfo({ type: 'presenter', status: isPresenter });
|
||||||
|
|
||||||
log.info('[Join] - Is presenter', {
|
log.info('[Join] - Is presenter', {
|
||||||
roomId: socket.room_id,
|
roomId: socket.room_id,
|
||||||
@@ -1070,7 +1072,9 @@ function startServer() {
|
|||||||
status: true,
|
status: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
await room.getPeers().get(socket.id).updatePeerInfo(data);
|
const peer = room.getPeers().get(socket.id);
|
||||||
|
|
||||||
|
peer.updatePeerInfo(data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const producer_id = await room.produce(
|
const producer_id = await room.produce(
|
||||||
@@ -1138,8 +1142,11 @@ function startServer() {
|
|||||||
|
|
||||||
const room = roomList.get(socket.room_id);
|
const room = roomList.get(socket.room_id);
|
||||||
|
|
||||||
|
const peer = room.getPeers().get(socket.id);
|
||||||
|
|
||||||
// peer_info audio Or video OFF
|
// peer_info audio Or video OFF
|
||||||
room.getPeers().get(socket.id).updatePeerInfo(data);
|
peer.updatePeerInfo(data);
|
||||||
|
|
||||||
room.closeProducer(socket.id, data.producer_id);
|
room.closeProducer(socket.id, data.producer_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1150,7 +1157,15 @@ function startServer() {
|
|||||||
|
|
||||||
const peer_name = getPeerName(room, false);
|
const peer_name = getPeerName(room, false);
|
||||||
|
|
||||||
const producer = room.getPeers()?.get(socket.id)?.getProducer(producer_id);
|
const peer = room.getPeers().get(socket.id);
|
||||||
|
|
||||||
|
if (!peer) {
|
||||||
|
return callback({
|
||||||
|
error: `peer with ID: ${socket.id} for producer with id "${producer_id}" not found`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const producer = peer.getProducer(producer_id);
|
||||||
|
|
||||||
if (!producer) {
|
if (!producer) {
|
||||||
return callback({ error: `producer with id "${producer_id}" not found` });
|
return callback({ error: `producer with id "${producer_id}" not found` });
|
||||||
@@ -1174,7 +1189,15 @@ function startServer() {
|
|||||||
|
|
||||||
const peer_name = getPeerName(room, false);
|
const peer_name = getPeerName(room, false);
|
||||||
|
|
||||||
const producer = room.getPeers()?.get(socket.id)?.getProducer(producer_id);
|
const peer = room.getPeers().get(socket.id);
|
||||||
|
|
||||||
|
if (!peer) {
|
||||||
|
return callback({
|
||||||
|
error: `peer with ID: "${socket.id}" for producer with id "${producer_id}" not found`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const producer = peer.getProducer(producer_id);
|
||||||
|
|
||||||
if (!producer) {
|
if (!producer) {
|
||||||
return callback({ error: `producer with id "${producer_id}" not found` });
|
return callback({ error: `producer with id "${producer_id}" not found` });
|
||||||
@@ -1227,7 +1250,9 @@ function startServer() {
|
|||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'privacy':
|
case 'privacy':
|
||||||
room.getPeers().get(socket.id).updatePeerInfo({ type: data.type, status: data.active });
|
const peer = room.getPeers().get(socket.id);
|
||||||
|
|
||||||
|
peer.updatePeerInfo({ type: data.type, status: data.active });
|
||||||
break;
|
break;
|
||||||
case 'ejectAll':
|
case 'ejectAll':
|
||||||
const { peer_name, peer_uuid } = data;
|
const { peer_name, peer_uuid } = data;
|
||||||
@@ -1388,7 +1413,9 @@ function startServer() {
|
|||||||
|
|
||||||
const room = roomList.get(socket.room_id);
|
const room = roomList.get(socket.room_id);
|
||||||
|
|
||||||
room.getPeers().get(socket.id).updatePeerInfo(data);
|
const peer = room.getPeers().get(socket.id);
|
||||||
|
|
||||||
|
peer.updatePeerInfo(data);
|
||||||
|
|
||||||
if (data.broadcast) {
|
if (data.broadcast) {
|
||||||
log.debug('updatePeerInfo broadcast data');
|
log.debug('updatePeerInfo broadcast data');
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم