[mirotalksfu] - refactoring, update dep
هذا الالتزام موجود في:
@@ -192,6 +192,23 @@ module.exports = class Room {
|
|||||||
this.peers.set(peer.id, peer);
|
this.peers.set(peer.id, peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPeer(socket_id) {
|
||||||
|
//
|
||||||
|
if (!this.peers.has(socket_id)) {
|
||||||
|
log.error('---> Peer not found for socket ID', socket_id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const peer = this.peers.get(socket_id);
|
||||||
|
|
||||||
|
if (!peer || typeof peer !== 'object') {
|
||||||
|
log.error('---> Peer object not found for socket ID', socket_id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return peer;
|
||||||
|
}
|
||||||
|
|
||||||
getPeers() {
|
getPeers() {
|
||||||
return this.peers;
|
return this.peers;
|
||||||
}
|
}
|
||||||
@@ -217,9 +234,12 @@ module.exports = class Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async removePeer(socket_id) {
|
async removePeer(socket_id) {
|
||||||
if (!this.peers.has(socket_id)) return;
|
|
||||||
|
|
||||||
const peer = this.peers.get(socket_id);
|
const peer = this.getPeer(socket_id);
|
||||||
|
|
||||||
|
if (!peer || typeof peer !== 'object') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { id, peer_name } = peer;
|
const { id, peer_name } = peer;
|
||||||
|
|
||||||
@@ -245,9 +265,6 @@ module.exports = class Room {
|
|||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
async createWebRtcTransport(socket_id) {
|
async createWebRtcTransport(socket_id) {
|
||||||
if (!this.peers.has(socket_id)) {
|
|
||||||
return this.callback(`[Room|createWebRtcTransport] Peer with socket ID ${socket_id} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { maxIncomingBitrate, initialAvailableOutgoingBitrate, listenInfos } = this.webRtcTransport;
|
const { maxIncomingBitrate, initialAvailableOutgoingBitrate, listenInfos } = this.webRtcTransport;
|
||||||
|
|
||||||
@@ -276,9 +293,13 @@ module.exports = class Room {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const peer = this.peers.get(socket_id);
|
const peer = this.getPeer(socket_id);
|
||||||
|
|
||||||
const { peer_name = 'undefined' } = peer;
|
if (!peer || typeof peer !== 'object') {
|
||||||
|
return this.callback(`[Room|createWebRtcTransport] Peer object not found for socket ID: ${socket_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { peer_name } = peer;
|
||||||
|
|
||||||
transport.on('icestatechange', (iceState) => {
|
transport.on('icestatechange', (iceState) => {
|
||||||
if (iceState === 'disconnected' || iceState === 'closed') {
|
if (iceState === 'disconnected' || iceState === 'closed') {
|
||||||
@@ -287,6 +308,7 @@ module.exports = class Room {
|
|||||||
iceState: iceState,
|
iceState: iceState,
|
||||||
});
|
});
|
||||||
transport.close();
|
transport.close();
|
||||||
|
this.removePeer(peer.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -304,6 +326,7 @@ module.exports = class Room {
|
|||||||
dtlsState: dtlsState,
|
dtlsState: dtlsState,
|
||||||
});
|
});
|
||||||
transport.close();
|
transport.close();
|
||||||
|
this.removePeer(peer.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -329,11 +352,11 @@ module.exports = class Room {
|
|||||||
return this.callback('[Room|connectPeerTransport] Invalid input parameters');
|
return this.callback('[Room|connectPeerTransport] Invalid input parameters');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.peers.has(socket_id)) {
|
const peer = this.getPeer(socket_id);
|
||||||
return this.callback(`[Room|connectPeerTransport] Peer with socket ID ${socket_id} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const peer = this.peers.get(socket_id);
|
if (!peer || typeof peer !== 'object') {
|
||||||
|
return this.callback(`[Room|connectPeerTransport] Peer object not found for socket ID: ${socket_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
const connectTransport = await peer.connectTransport(transport_id, dtlsParameters);
|
const connectTransport = await peer.connectTransport(transport_id, dtlsParameters);
|
||||||
|
|
||||||
@@ -358,11 +381,11 @@ module.exports = class Room {
|
|||||||
return this.callback('[Room|produce] Invalid input parameters');
|
return this.callback('[Room|produce] Invalid input parameters');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.peers.has(socket_id)) {
|
const peer = this.getPeer(socket_id);
|
||||||
return this.callback(`[Room|produce] Peer with ID: ${socket_id} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const peer = this.peers.get(socket_id);
|
if (!peer || typeof peer !== 'object') {
|
||||||
|
return this.callback(`[Room|produce] Peer object not found for socket ID: ${socket_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
const peerProducer = await peer.createProducer(producerTransportId, rtpParameters, kind, type);
|
const peerProducer = await peer.createProducer(producerTransportId, rtpParameters, kind, type);
|
||||||
|
|
||||||
@@ -372,7 +395,7 @@ module.exports = class Room {
|
|||||||
|
|
||||||
const { id } = peerProducer;
|
const { id } = peerProducer;
|
||||||
|
|
||||||
const { peer_name = 'undefined', peer_info = {} } = peer;
|
const { peer_name, peer_info } = peer;
|
||||||
|
|
||||||
this.broadCast(socket_id, 'newProducers', [
|
this.broadCast(socket_id, 'newProducers', [
|
||||||
{
|
{
|
||||||
@@ -406,15 +429,12 @@ module.exports = class Room {
|
|||||||
return this.callback(`[Room|consume] Room router cannot consume producer_id: '${producer_id}'`);
|
return this.callback(`[Room|consume] Room router cannot consume producer_id: '${producer_id}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.peers.has(socket_id)) {
|
const peer = this.getPeer(socket_id);
|
||||||
log.warn('Peer not found for socket ID', socket_id);
|
|
||||||
return this.callback(`[Room|consume] Peer with ID: ${socket_id} not found`);
|
if (!peer || typeof peer !== 'object') {
|
||||||
|
return this.callback(`[Room|consume] Peer object not found for socket ID: ${socket_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const peer = this.peers.get(socket_id);
|
|
||||||
|
|
||||||
const { peer_name = 'undefined' } = peer;
|
|
||||||
|
|
||||||
const peerConsumer = await peer.createConsumer(consumer_transport_id, producer_id, rtpCapabilities);
|
const peerConsumer = await peer.createConsumer(consumer_transport_id, producer_id, rtpCapabilities);
|
||||||
|
|
||||||
if (!peerConsumer || !peerConsumer.consumer || !peerConsumer.params) {
|
if (!peerConsumer || !peerConsumer.consumer || !peerConsumer.params) {
|
||||||
@@ -426,6 +446,8 @@ module.exports = class Room {
|
|||||||
|
|
||||||
const { id, kind } = consumer;
|
const { id, kind } = consumer;
|
||||||
|
|
||||||
|
const { peer_name } = peer;
|
||||||
|
|
||||||
consumer.on('producerclose', () => {
|
consumer.on('producerclose', () => {
|
||||||
log.debug('Consumer closed due to producerclose event', {
|
log.debug('Consumer closed due to producerclose event', {
|
||||||
peer_name: peer_name,
|
peer_name: peer_name,
|
||||||
@@ -448,11 +470,17 @@ 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) return;
|
||||||
|
|
||||||
const peer = this.peers.get(socket_id);
|
const peer = this.getPeer(socket_id);
|
||||||
|
|
||||||
|
if (!peer || typeof peer !== 'object') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
peer.closeProducer(producer_id);
|
peer.closeProducer(producer_id);
|
||||||
|
|
||||||
|
log.debug('Producer closed', producer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ dependencies: {
|
|||||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||||
* @version 1.3.97
|
* @version 1.3.98
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1700,7 +1700,7 @@ function startServer() {
|
|||||||
|
|
||||||
log.debug('[Disconnect] - peer name', peerName);
|
log.debug('[Disconnect] - peer name', peerName);
|
||||||
|
|
||||||
room.removePeer(socket.id);
|
// room.removePeer(socket.id); // handled on WebRtcTransport - transport.close()
|
||||||
|
|
||||||
if (room.getPeers().size === 0) {
|
if (room.getPeers().size === 0) {
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mirotalksfu",
|
"name": "mirotalksfu",
|
||||||
"version": "1.3.97",
|
"version": "1.3.98",
|
||||||
"description": "WebRTC SFU browser-based video calls",
|
"description": "WebRTC SFU browser-based video calls",
|
||||||
"main": "Server.js",
|
"main": "Server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
"mediasoup": "3.13.24",
|
"mediasoup": "3.13.24",
|
||||||
"mediasoup-client": "3.7.6",
|
"mediasoup-client": "3.7.6",
|
||||||
"ngrok": "^5.0.0-beta.2",
|
"ngrok": "^5.0.0-beta.2",
|
||||||
"openai": "^4.29.1",
|
"openai": "^4.29.2",
|
||||||
"qs": "6.12.0",
|
"qs": "6.12.0",
|
||||||
"socket.io": "4.7.5",
|
"socket.io": "4.7.5",
|
||||||
"swagger-ui-express": "5.0.0",
|
"swagger-ui-express": "5.0.0",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
|
|||||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||||
* @version 1.3.97
|
* @version 1.3.98
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم