getCallState() method

If a call object is added to the program, this method can run on it. It is used to find out the current callstate of the call. The callstates can be: "RINGING", "NOT_FOUND", "REJECTED", "HOLD", "IN_CALL", "COMPLETED" and "BUSY".

Returns

currentCallState: Type: CallState. The current state of the call.

Method usage example

In this example we make the myFirstCall object in the call class, we set the called number and start the call. After this we write out the current callstate on the console in every 2 seconds until the call ends. We check if the call has been completed by registering on the onCallStateChanged event (Code example 1).

var calledNumber = "1000";

//constructor of the call
var myFirstCall = OzWebClient.createCall(calledNumber); 

myFirstCall.start();	//starts the call

//registers to the onCallStateChanged event
myFirstCall.onCallStateChanged(callStateChanged); 

loop(); //starts the loop	

function loop(){
	if(myFirstCall != null){ //if there is a call
	
		//start the loop recursively in every 2 seconds and
		setTimeout('loop()',2000); 
		
		//write the current callstate on the console log
		console.log(myFirstCall.getCallState()); 
	}
}

function callStateChanged(state){
	if (state = "COMPLETED"){ //if the call is completed it
		myFirstCall=null; //deletes the call
	}
}
	
Code example 1 - getCallState() method example

More information