function init()

in Frontend/main.js [163:233]


function init() {
//Instantiate the CCP in the custom page if not already initated
    if (!window.connect.core.initialized) {
        connect.core.initCCP(document.getElementById(ccpDomElement), ccpParams);
    }
    connect.agent(function(agent) {
    //here we subscribe to agent updates
        console.log('Agent Configuration on Page load');
        console.log(agent.getConfiguration());
        currentAgent = agent;
        //keep agent status up to date
        agent.onRefresh(function(agent) {
            currentAgent = agent;
        });
    });

    connect.contact(function(contact) {
    //This function subscribes to contact actions to store the contact trace details
        //currentContact = contact; //set the latest contact global variable for debugging purposes

        contact.onRefresh(function(contact){
            storeContactTraceStream(contact, currentAgent, 'Refresh');
        });

        //function to be invoked on incoming call
        contact.onIncoming(function(contact) { 
            storeContactTraceStream(contact, currentAgent, 'Incoming');
        });

        //function to be invoked on pending call
        contact.onPending(function(contact) { 
            storeContactTraceStream(contact, currentAgent, 'Pending');
        });

        //function to be invoked on connecting call
        contact.onConnecting(function(contact) { 
            storeContactTraceStream(contact, currentAgent, 'Connecting');
        });

        //function to be invoked on accepted contact
        contact.onAccepted(function(contact){
            storeContactTraceStream(contact, currentAgent, 'Accepted');      
        });

        //function to be invoked on missed contact
        contact.onMissed(function(contact){
            storeContactTraceStream(contact, currentAgent, 'Missed');
        });

        //function to be invoked on connected contact
        contact.onConnected(function(contact){
            storeContactTraceStream(contact, currentAgent, 'Connected');
        });

        //function to be invoked on after contact work state
        contact.onACW(function(contact) {
            storeContactTraceStream(contact, currentAgent, 'ACW');
        });

        //function to be invoked on contact ended
        contact.onEnded(function(contact) {
            storeContactTraceStream(contact, currentAgent, 'Ended');
        });

        //function to be invoked on contact destroy
         contact.onDestroy(function(contact) {
            storeContactTraceStream(contact, currentAgent, 'Destroyed');
         });

    });
}