Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'jssip' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
/*jshint -W083 */
import JsSIP from 'jssip';
JsSIP.debug.enable('JsSIP:*');
let useragent /* jssip instance */;
let runningConfiguration /* jssip configuration */;
let makecall /* callback for registered jssip */;
let cachedPCConfig /* cached peer connection config */;
module.exports = controller => {
controller.registerTrigger('findDatabase::instantSearch', 'softphone', (args, callback) => {
callback();
let [text, modal] = args;
if (!/phone|limpar|configuração/i.test(text)) {
return;
}
componentDidMount()
{
this._mounted = true;
const settings = this.props.settings;
const socket = new JsSIP.WebSocketInterface(settings.socket.uri);
if (settings.socket['via_transport'] !== 'auto')
socket['via_transport'] = settings.socket['via_transport'];
try
{
this._ua = new JsSIP.UA(
{
uri : settings.uri,
password : settings.password,
'display_name' : settings.display_name,
sockets : [ socket ],
'registrar_server' : settings.registrar_server,
'contact_uri' : settings.contact_uri,
'authorization_user' : settings.authorization_user,
'instance_id' : settings.instance_id,
'session_timers' : settings.session_timers,
'use_preloaded_route' : settings.use_preloaded_route
});
// TODO: For testing.
window.UA = this._ua;
}
controller.call('softphone::configuration', configuration => {
useragent = new JsSIP.UA(configuration);
let events = ['connected', 'disconnected', 'registered', 'unregistered', 'registrationFailed', 'newSession', 'newMessage'];
for (let event of events) {
useragent.on(event, function(...args) {
controller.trigger(`softphone::${event}`, Array.from(args));
});
}
runningConfiguration = configuration;
useragent.start();
});
});
componentWillUnmount()
{
logger.debug('componentWillUnmount()');
this._mounted = false;
JsSIP.Utils.closeMediaStream(this._localClonedStream);
}
componentDidMount()
{
this._mounted = true;
const settings = this.props.settings;
const socket = new JsSIP.WebSocketInterface(settings.socket.uri);
if (settings.socket['via_transport'] !== 'auto')
socket['via_transport'] = settings.socket['via_transport'];
try
{
this._ua = new JsSIP.UA(
{
uri : settings.uri,
password : settings.password,
'display_name' : settings.display_name,
sockets : [ socket ],
'registrar_server' : settings.registrar_server,
'contact_uri' : settings.contact_uri,
'authorization_user' : settings.authorization_user,
'instance_id' : settings.instance_id,
socket: new WebSocketInterface(`wss://${urls[0]}:4443`),
weight: 20,
},
{
socket: new WebSocketInterface(`wss://${urls[1]}:4443`),
weight: 10,
},
];
this.micMuted = false;
this.qualityOfServiceEmitter = null;
this.outputVolume = 1;
this.isRegistered = false;
this.onCallAction = () => {};
this.onUserAgentAction = this.params.onUserAgentAction;
this.sipUserAgent = new UA({
sockets,
uri: `sip:${this.params.callerId}@wss.flowroute.com`,
password: this.params.password,
display_name: this.params.displayName,
});
this.sipUserAgent.on('newRTCSession', this.handleNewRTCSession.bind(this));
this.sipUserAgent.on('registered', (payload) => {
this.isRegistered = true;
this.onUserAgentAction({ type: 'registered', payload });
});
const defaultAgentEventsToHandle = [
'connecting',
'connected',
password: 'nopassword',
extraHeaders: [],
debug: false,
intervalOfQualityReport: undefined,
onUserAgentAction: () => {},
...params,
};
const urls = FR_POINTS_OF_PRESENCE_DOMAINS[this.params.pointOfPresence];
const sockets = [
{
socket: new WebSocketInterface(`wss://${urls[0]}:4443`),
weight: 20,
},
{
socket: new WebSocketInterface(`wss://${urls[1]}:4443`),
weight: 10,
},
];
this.micMuted = false;
this.qualityOfServiceEmitter = null;
this.outputVolume = 1;
this.isRegistered = false;
this.onCallAction = () => {};
this.onUserAgentAction = this.params.onUserAgentAction;
this.sipUserAgent = new UA({
sockets,
uri: `sip:${this.params.callerId}@wss.flowroute.com`,
password: this.params.password,
display_name: this.params.displayName,
});
start() {
if (this.params.debug) {
debug.enable('JsSIP:*');
} else {
debug.disable('JsSIP:*');
}
this.sipUserAgent.start();
}
start() {
if (this.params.debug) {
debug.enable('JsSIP:*');
} else {
debug.disable('JsSIP:*');
}
this.sipUserAgent.start();
}