The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/voip/server/startup.ts

30 lines
873 B

import { Voip } from '@rocket.chat/core-services';
import { settings } from '../../settings/server';
settings.watch('VoIP_Enabled', async function (value: boolean) {
try {
if (value) {
await Voip.init();
} else {
await Voip.stop();
}
} catch (e) {
// do nothing
}
});
settings.changeMultiple(
['VoIP_Management_Server_Host', 'VoIP_Management_Server_Port', 'VoIP_Management_Server_Username', 'VoIP_Management_Server_Password'],
async function (_values) {
// Here, if 4 settings are changed at once, we're getting 4 diff callbacks. The good part is that all callbacks are fired almost instantly
// So to avoid stopping/starting voip too often, we debounce the call and restart 1 second after the last setting has reached us.
if (settings.get('VoIP_Enabled')) {
try {
await Voip.refresh();
} catch (e) {
// do nothing
}
}
},
);