[mirotalksfu] - refactoring
هذا الالتزام موجود في:
@@ -114,8 +114,7 @@ module.exports = class Peer {
|
|||||||
paused: false,
|
paused: false,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Consume failed', error);
|
return console.error('Consume failed', error);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consumer.type === 'simulcast') {
|
if (consumer.type === 'simulcast') {
|
||||||
|
|||||||
@@ -217,12 +217,11 @@ module.exports = class Room {
|
|||||||
rtpCapabilities,
|
rtpCapabilities,
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
log.error('Can not consume', {
|
return log.error('Can not consume', {
|
||||||
socket_id: socket_id,
|
socket_id: socket_id,
|
||||||
consumer_transport_id: consumer_transport_id,
|
consumer_transport_id: consumer_transport_id,
|
||||||
producer_id: producer_id,
|
producer_id: producer_id,
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { consumer, params } = await this.peers
|
let { consumer, params } = await this.peers
|
||||||
|
|||||||
@@ -393,8 +393,7 @@ httpsServer.listen(config.listenPort, () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (config.ngrokAuthToken !== '') {
|
if (config.ngrokAuthToken !== '') {
|
||||||
ngrokStart();
|
return ngrokStart();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
log.debug('Settings', {
|
log.debug('Settings', {
|
||||||
node_version: process.versions.node,
|
node_version: process.versions.node,
|
||||||
|
|||||||
@@ -260,8 +260,7 @@ class RoomClient {
|
|||||||
if (room === 'isLocked') {
|
if (room === 'isLocked') {
|
||||||
this.event(_EVENTS.roomLock);
|
this.event(_EVENTS.roomLock);
|
||||||
console.log('00-WARNING ----> Room is Locked, Try to unlock by the password');
|
console.log('00-WARNING ----> Room is Locked, Try to unlock by the password');
|
||||||
this.unlockTheRoom();
|
return this.unlockTheRoom();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
await this.joinAllowed(room);
|
await this.joinAllowed(room);
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
@@ -337,8 +336,7 @@ class RoomClient {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
console.error('Create WebRtc Transport for Producer err: ', data.error);
|
return console.error('Create WebRtc Transport for Producer err: ', data.error);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.producerTransport = device.createSendTransport(data);
|
this.producerTransport = device.createSendTransport(data);
|
||||||
@@ -406,8 +404,7 @@ class RoomClient {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
console.error('Create WebRtc Transport for Consumer err: ', data.error);
|
return console.error('Create WebRtc Transport for Consumer err: ', data.error);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.consumerTransport = device.createRecvTransport(data);
|
this.consumerTransport = device.createRecvTransport(data);
|
||||||
@@ -690,12 +687,10 @@ class RoomClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.device.canProduce('video') && !audio) {
|
if (!this.device.canProduce('video') && !audio) {
|
||||||
console.error('Cannot produce video');
|
return console.error('Cannot produce video');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (this.producerLabel.has(type)) {
|
if (this.producerLabel.has(type)) {
|
||||||
console.log('Producer already exists for this type ' + type);
|
return console.log('Producer already exists for this type ' + type);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
console.log(`Media contraints ${type}:`, mediaConstraints);
|
console.log(`Media contraints ${type}:`, mediaConstraints);
|
||||||
let stream;
|
let stream;
|
||||||
@@ -990,8 +985,7 @@ class RoomClient {
|
|||||||
|
|
||||||
pauseProducer(type) {
|
pauseProducer(type) {
|
||||||
if (!this.producerLabel.has(type)) {
|
if (!this.producerLabel.has(type)) {
|
||||||
console.log('There is no producer for this type ' + type);
|
return console.log('There is no producer for this type ' + type);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let producer_id = this.producerLabel.get(type);
|
let producer_id = this.producerLabel.get(type);
|
||||||
@@ -1014,8 +1008,7 @@ class RoomClient {
|
|||||||
|
|
||||||
resumeProducer(type) {
|
resumeProducer(type) {
|
||||||
if (!this.producerLabel.has(type)) {
|
if (!this.producerLabel.has(type)) {
|
||||||
console.log('There is no producer for this type ' + type);
|
return console.log('There is no producer for this type ' + type);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let producer_id = this.producerLabel.get(type);
|
let producer_id = this.producerLabel.get(type);
|
||||||
@@ -1038,8 +1031,7 @@ class RoomClient {
|
|||||||
|
|
||||||
closeProducer(type) {
|
closeProducer(type) {
|
||||||
if (!this.producerLabel.has(type)) {
|
if (!this.producerLabel.has(type)) {
|
||||||
console.log('There is no producer for this type ' + type);
|
return console.log('There is no producer for this type ' + type);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let producer_id = this.producerLabel.get(type);
|
let producer_id = this.producerLabel.get(type);
|
||||||
@@ -2081,13 +2073,11 @@ class RoomClient {
|
|||||||
if (!this.thereIsParticipants()) {
|
if (!this.thereIsParticipants()) {
|
||||||
this.cleanMessage();
|
this.cleanMessage();
|
||||||
isChatPasteTxt = false;
|
isChatPasteTxt = false;
|
||||||
this.userLog('info', 'No participants in the room', 'top-end');
|
return this.userLog('info', 'No participants in the room', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let peer_msg = this.formatMsg(chatMessage.value);
|
let peer_msg = this.formatMsg(chatMessage.value);
|
||||||
if (!peer_msg) {
|
if (!peer_msg) {
|
||||||
this.cleanMessage();
|
return this.cleanMessage();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let data = {
|
let data = {
|
||||||
peer_name: this.peer_name,
|
peer_name: this.peer_name,
|
||||||
@@ -2106,8 +2096,7 @@ class RoomClient {
|
|||||||
if (!this.thereIsParticipants()) {
|
if (!this.thereIsParticipants()) {
|
||||||
isChatPasteTxt = false;
|
isChatPasteTxt = false;
|
||||||
this.cleanMessage();
|
this.cleanMessage();
|
||||||
this.userLog('info', 'No participants in the room expect you', 'top-end');
|
return this.userLog('info', 'No participants in the room expect you', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
background: swalBackground,
|
background: swalBackground,
|
||||||
@@ -2127,8 +2116,7 @@ class RoomClient {
|
|||||||
if (result.value) {
|
if (result.value) {
|
||||||
let peer_msg = this.formatMsg(result.value);
|
let peer_msg = this.formatMsg(result.value);
|
||||||
if (!peer_msg) {
|
if (!peer_msg) {
|
||||||
this.cleanMessage();
|
return this.cleanMessage();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let data = {
|
let data = {
|
||||||
peer_name: this.peer_name,
|
peer_name: this.peer_name,
|
||||||
@@ -2330,8 +2318,7 @@ class RoomClient {
|
|||||||
|
|
||||||
chatClean() {
|
chatClean() {
|
||||||
if (this.chatMessages.length === 0) {
|
if (this.chatMessages.length === 0) {
|
||||||
userLog('info', 'No chat messages to clean', 'top-end');
|
return userLog('info', 'No chat messages to clean', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
background: swalBackground,
|
background: swalBackground,
|
||||||
@@ -2362,8 +2349,7 @@ class RoomClient {
|
|||||||
|
|
||||||
chatSave() {
|
chatSave() {
|
||||||
if (this.chatMessages.length === 0) {
|
if (this.chatMessages.length === 0) {
|
||||||
userLog('info', 'No chat messages to save', 'top-end');
|
return userLog('info', 'No chat messages to save', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const newDate = new Date();
|
const newDate = new Date();
|
||||||
@@ -2437,8 +2423,7 @@ class RoomClient {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Exception while creating MediaRecorder: ', err);
|
console.error('Exception while creating MediaRecorder: ', err);
|
||||||
this.userLog('error', "Can't start stream recording reason: " + err, 'top-end');
|
return this.userLog('error', "Can't start stream recording reason: " + err, 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2553,23 +2538,19 @@ class RoomClient {
|
|||||||
videoPlayer.addEventListener('drop', function (e) {
|
videoPlayer.addEventListener('drop', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (itsMe) {
|
if (itsMe) {
|
||||||
userLog('warning', 'You cannot send files to yourself.', 'top-end');
|
return userLog('warning', 'You cannot send files to yourself.', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (this.sendInProgress) {
|
if (this.sendInProgress) {
|
||||||
userLog('warning', 'Please wait for the previous file to be sent.', 'top-end');
|
return userLog('warning', 'Please wait for the previous file to be sent.', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (e.dataTransfer.items && e.dataTransfer.items.length > 1) {
|
if (e.dataTransfer.items && e.dataTransfer.items.length > 1) {
|
||||||
userLog('warning', 'Please drag and drop a single file.', 'top-end');
|
return userLog('warning', 'Please drag and drop a single file.', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (e.dataTransfer.items) {
|
if (e.dataTransfer.items) {
|
||||||
let item = e.dataTransfer.items[0].webkitGetAsEntry();
|
let item = e.dataTransfer.items[0].webkitGetAsEntry();
|
||||||
console.log('Drag and drop', item);
|
console.log('Drag and drop', item);
|
||||||
if (item.isDirectory) {
|
if (item.isDirectory) {
|
||||||
userLog('warning', 'Please drag and drop a single file not a folder.', 'top-end');
|
return userLog('warning', 'Please drag and drop a single file not a folder.', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var file = e.dataTransfer.items[0].getAsFile();
|
var file = e.dataTransfer.items[0].getAsFile();
|
||||||
rc.sendFileInformations(file, peer_id);
|
rc.sendFileInformations(file, peer_id);
|
||||||
@@ -2616,8 +2597,7 @@ class RoomClient {
|
|||||||
//
|
//
|
||||||
if (this.fileToSend && this.fileToSend.size > 0) {
|
if (this.fileToSend && this.fileToSend.size > 0) {
|
||||||
if (!this.thereIsParticipants()) {
|
if (!this.thereIsParticipants()) {
|
||||||
userLog('info', 'No participants detected', 'top-end');
|
return userLog('info', 'No participants detected', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let fileInfo = {
|
let fileInfo = {
|
||||||
peer_id: peer_id,
|
peer_id: peer_id,
|
||||||
@@ -2901,12 +2881,10 @@ class RoomClient {
|
|||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result.value) {
|
if (result.value) {
|
||||||
if (!this.thereIsParticipants()) {
|
if (!this.thereIsParticipants()) {
|
||||||
userLog('info', 'No participants detected', 'top-end');
|
return userLog('info', 'No participants detected', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!this.isVideoTypeSupported(result.value)) {
|
if (!this.isVideoTypeSupported(result.value)) {
|
||||||
userLog('warning', 'Something wrong, try with another Video or audio URL');
|
return userLog('warning', 'Something wrong, try with another Video or audio URL');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
https://www.youtube.com/watch?v=RT6_Id5-7-s
|
https://www.youtube.com/watch?v=RT6_Id5-7-s
|
||||||
@@ -3312,8 +3290,7 @@ class RoomClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!this.thereIsParticipants()) {
|
if (!this.thereIsParticipants()) {
|
||||||
if (info) this.userLog('info', 'No participants detected', 'top-end');
|
if (info) return this.userLog('info', 'No participants detected', 'top-end');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this.confirmPeerAction(action, data);
|
this.confirmPeerAction(action, data);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ adjective = adjective.charAt(0).toUpperCase() + adjective.substring(1);
|
|||||||
document.getElementById('roomName').value = '';
|
document.getElementById('roomName').value = '';
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
// TYPPING EFECT
|
// TYPING EFFECT
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم