function initAgentLibrarySoftphoneService(context) {
/**
* @namespace Softphone
* @memberof AgentLibrary
*/
'use strict';
var AgentLibrary = context.AgentLibrary;
var agentAuthRequest = UIModel.getInstance().authenticateRequest;
// Auth token ,agentId,dialDest will be passed in init() function when sipInit is initialized in AgentJs.
var serviceInstance = new SoftphoneService({
authToken: agentAuthRequest && agentAuthRequest.engageAccessToken,
agentId: UIModel.getInstance().agentSettings.agentId,
});
// set the softphone instance on the Lib
AgentLibrary.prototype._SoftphoneService = serviceInstance;
//////////////////////
// PUBLIC FUNCTIONS //
//////////////////////
/* These functions are available externally to agent-js or other parent apps */
/**
* Initializes the SIP library, sets up callback functions
* @memberof AgentLibrary.Softphone
*/
AgentLibrary.prototype.sipInit = serviceInstance.sipInit.bind(
serviceInstance
);
/**
* clear webRtc settings, hangup, unregister
* @memberof SoftphoneLibrary
* @returns boolean - success state
*/
AgentLibrary.prototype.sipTerminate = serviceInstance.sipTerminate.bind(
serviceInstance
);
/**
* Sends a session.accept response to a SIP invite event.
* @memberof AgentLibrary.Softphone
*/
AgentLibrary.prototype.sipAnswer = serviceInstance.sipAnswer.bind(
serviceInstance
);
/**
* Sends a session.reject response to a SIP invite event.
* @memberof AgentLibrary.Softphone
*/
AgentLibrary.prototype.sipReject = serviceInstance.sipReject.bind(
serviceInstance
);
/**
* Request microphone access, if already registered, call hangup
* @memberof AgentLibrary.Softphone
*/
AgentLibrary.prototype.sipRegister = serviceInstance.sipRegister.bind(
serviceInstance
);
/**
* Sends session.cancel if connected, or session.bye if not connected to a call
* @memberof AgentLibrary.Softphone
*/
AgentLibrary.prototype.sipHangUp = serviceInstance.sipHangUp.bind(
serviceInstance
);
/**
* Sends session.dtmf for the tone specified
* @memberof AgentLibrary.Softphone
* @param {string} dtmf The dtmf tone to send
*/
AgentLibrary.prototype.sipSendDTMF = serviceInstance.sipSendDTMF.bind(
serviceInstance
);
/**
* Toggles call audio on/off
* @memberof AgentLibrary.Softphone
* @param {boolean} state The dtmf tone to send
*/
AgentLibrary.prototype.sipToggleMute = serviceInstance.sipToggleMute.bind(
serviceInstance
);
AgentLibrary.prototype.switchSoftphoneRegistrar = serviceInstance.switchSoftphoneRegistrar.bind(
serviceInstance
);
AgentLibrary.prototype.resetSoftphoneSession = serviceInstance.resetSoftphoneSession.bind(
serviceInstance
);
/**
* Initializes the SIP library, sets up callback functions
* Request microphone access, if already registered, call hangup
* @memberof AgentLibrary.Softphone
*/
AgentLibrary.prototype.sipInitAndRegister = serviceInstance.sipInitAndRegister.bind(
serviceInstance
);
}