2022-02-15 23:54:55 +08:00
|
|
|
import { showModal } from '/imports/ui/components/common/modal/service';
|
2020-03-03 04:49:15 +08:00
|
|
|
import Service from '../service';
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
import Storage from '/imports/ui/services/storage/session';
|
2020-03-03 04:49:15 +08:00
|
|
|
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
const CLIENT_DID_USER_SELECTED_MICROPHONE_KEY = 'clientUserSelectedMicrophone';
|
|
|
|
const CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY = 'clientUserSelectedListenOnly';
|
2020-03-03 04:49:15 +08:00
|
|
|
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
export const setUserSelectedMicrophone = (value) => (
|
|
|
|
Storage.setItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY, !!value)
|
|
|
|
);
|
2020-03-03 04:49:15 +08:00
|
|
|
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
export const setUserSelectedListenOnly = (value) => (
|
|
|
|
Storage.setItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY, !!value)
|
|
|
|
);
|
|
|
|
|
|
|
|
export const didUserSelectedMicrophone = () => (
|
|
|
|
!!Storage.getItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY)
|
|
|
|
);
|
|
|
|
|
|
|
|
export const didUserSelectedListenOnly = () => (
|
|
|
|
!!Storage.getItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY)
|
|
|
|
);
|
2020-03-03 04:49:15 +08:00
|
|
|
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
export const joinMicrophone = (skipEchoTest = false) => {
|
|
|
|
Storage.setItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY, true);
|
|
|
|
Storage.setItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY, false);
|
2020-03-03 04:49:15 +08:00
|
|
|
|
|
|
|
const call = new Promise((resolve, reject) => {
|
2021-05-04 06:26:47 +08:00
|
|
|
try {
|
2022-04-12 04:18:43 +08:00
|
|
|
if ((skipEchoTest && !Service.isConnected()) || Service.localEchoEnabled) {
|
2021-05-04 06:26:47 +08:00
|
|
|
return resolve(Service.joinMicrophone());
|
|
|
|
}
|
|
|
|
|
|
|
|
return resolve(Service.transferCall());
|
|
|
|
} catch {
|
|
|
|
return reject(Service.exitAudio);
|
2020-03-03 04:49:15 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return call.then(() => {
|
|
|
|
showModal(null);
|
|
|
|
}).catch((error) => {
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const joinListenOnly = () => {
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
Storage.setItem(CLIENT_DID_USER_SELECTED_MICROPHONE_KEY, false);
|
|
|
|
Storage.setItem(CLIENT_DID_USER_SELECTED_LISTEN_ONLY_KEY, true);
|
|
|
|
|
2020-03-03 04:49:15 +08:00
|
|
|
const call = new Promise((resolve) => {
|
|
|
|
Service.joinListenOnly().then(() => {
|
|
|
|
// Autoplay block wasn't triggered. Close the modal. If autoplay was
|
|
|
|
// blocked, that'll be handled in the modal component when then
|
|
|
|
// prop transitions to a state where it was handled OR the user opts
|
|
|
|
// to close the modal.
|
|
|
|
if (!Service.autoplayBlocked()) {
|
|
|
|
showModal(null);
|
|
|
|
}
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return call.catch((error) => {
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const leaveEchoTest = () => {
|
|
|
|
if (!Service.isEchoTest()) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
return Service.exitAudio();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const closeModal = () => {
|
2021-12-03 19:45:07 +08:00
|
|
|
if (Service.isConnecting()) {
|
|
|
|
Service.forceExitAudio();
|
|
|
|
}
|
|
|
|
showModal(null);
|
2020-03-03 04:49:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
joinMicrophone,
|
|
|
|
closeModal,
|
|
|
|
joinListenOnly,
|
|
|
|
leaveEchoTest,
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
didUserSelectedMicrophone,
|
|
|
|
didUserSelectedListenOnly,
|
2020-03-03 04:49:15 +08:00
|
|
|
};
|