public class CallDemo
{
    public static void main(String args[]) throws Exception
    {
	SimpleCapi capi = new SimpleCapi("127.0.0.1", 7347);
	if(capi.call("1234", 60) == 0) {
	    capi.play("test.wav");
	    while(true) {
		CapiEvent event = capi.listen(3);
		if(event.type == SimpleCapi.TIMEOUT)
		    continue;
		
		System.out.println(event);

		if(event.type == SimpleCapi.CAPI_EVENT_HANGUP)
		    break;
		if(event.type == SimpleCapi.CAPI_EVENT_DONE) { // soundfile done playing - hang up
		    capi.hangup();
		    break;
		}
	    }
	} else {
	    System.out.println("Couldn't connect!\n");
	}
    }
}
