i use jtapi with xtapi and mstapi for my IVR project. But i have a problem with CallCtlTermConnDroppedEv. It doesnt work, although the incall is shutted down by the caller.thus the line remains bussy after the first incall.here is my code snippet :
class MyCallCtlInCallObserver2 extends BasicMediaService implements CallControlCallObserver { public MyCallCtlInCallObserver2(MediaProvider mp){ super(mp); } public void callChangedEvent(CallEv[] evlist) { int state = 0; TerminalConnection termconn; String name;
for (int i = 0; i < evlist.length; i++) { CallEv ev=evlist; TerminalConnection tc = ((TermConnEv)ev).getTerminalConnection(); MediaTerminalConnection mtc = (MediaTerminalConnection)tc; if (evlist instanceof TermConnEv) { termconn = null; mtc = null; name = null;
mtc.usePlayURL(new URL("file:C:/Documents and Settings/yazici/IdeaProjects/xtapi/src/Greeting.wav")); System.out.println("Playing Greetings..."); mtc.startPlaying(); System.out.println("After Playing MediaState="); mtc.setDtmfDetection(true); } catch (Exception excp) { System.out.println("media hata1-> "+excp); System.exit(0); } }// else if (evlist.getID() == TermConnRingingEv.ID) { System.out.println(msg + "RINGING"); try { final TerminalConnection _tc = termconn; Runnable r = new Runnable() { public void run() { try{ _tc.answer(); } catch (Exception excp){ // Handle answer exceptions System.out.println( "hata2"); } }; }; Thread T = new Thread(r); T.start(); } catch (Exception excp) { // Handle Exceptions; System.out.println( "hata3"); } }
else if (ev instanceof MediaTermConnUnavailableEv) {
/* Turn off DTMF-detection */
try { mtc.setDtmfDetection(false); } catch (Exception excp) { // Handle exceptions } } else if (ev instanceof MediaTermConnDtmfEv) { /* Print out the DTMF digits */ char digit = ((MediaTermConnDtmfEv)ev).getDtmfDigit(); System.out.println("detected DTMF: " + digit); try{ // Echo out the same digit we detected //mtc.generateDtmf(digit + ""); }catch(Exception e){ System.out.println("Exception generateDtmf: " + e.toString()); } } else if (evlist.getID() == CallCtlTermConnDroppedEv.ID) { System.out.println(msg + "DROPPED"); } } } } } /* * Create a provider and monitor a particular terminal for an incoming call. */ public class CallCtlIncall2 { static String[] mypro; public static final void main(String args[]) {
/* * Create a provider by first obtaining the default implementation of * JTAPI and then the default provider of that implementation. */ Provider myprovider = null; try { JtapiPeer peer = JtapiPeerFactory.getJtapiPeer("net.xtapi.XJtapiPeer"); myprovider = peer.getProvider("MSTAPI"); System.out.println(myprovider.getTerminals()); mypro=peer.getServices(); } catch (Exception excp) { System.out.println("Can't get Provider: " + excp.toString()); System.out.println(mypro); System.exit(0); }
Hi Omer, Were you able to get solution to the above problem. I am also facing the same problem. I could play the Sound file for the first time but when I run second time I can't Please let me know