The Artima Developer Community
Sponsored Link

Java Answers Forum
a jtapi problem

1 reply on 1 page. Most recent reply: May 31, 2007 11:22 PM by Vijay Rawat

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
omer

Posts: 1
Nickname: cavalog
Registered: May, 2005

a jtapi problem Posted: May 2, 2005 4:38 PM
Reply to this message Reply
Advertisement
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 :

import javax.sound.sampled.*;
import javax.telephony.Provider;
import javax.telephony.JtapiPeer;
import javax.telephony.JtapiPeerFactory;

import javax.telephony.*;
import javax.telephony.media.*;
import javax.telephony.media.MediaTerminalConnection;
import javax.telephony.media.events.MediaTermConnAvailableEv;
import javax.telephony.media.events.MediaTermConnUnavailableEv;
import javax.telephony.media.events.MediaTermConnDtmfEv;
import javax.telephony.events.*;
import javax.telephony.callcontrol.*;
import javax.telephony.callcontrol.events.*;
import java.net.URL;

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;

try {
TermConnEv tcev = (TermConnEv)evlist;
termconn = tcev.getTerminalConnection();
Terminal term = termconn.getTerminal();
name = term.getName();
} catch (Exception excp) {
// Handle exceptions.
System.out.println( "hata1 -->> "+excp);
}

String msg = "TerminalConnection to Terminal: " + name + " is ";
if(evlist instanceof TermConnCreatedEv){

try {

} catch (Exception excp) {
System.out.println("url hata"+excp);
}
}
if (evlist.getID()==MediaTermConnAvailableEv.ID ) {
System.out.println(msg + "AKT&#304;VE");
System.out.println("Media Available...");
try {

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);
}

try {

Terminal terminal=myprovider.getTerminal("0");

System.out.println(terminal.getName());

terminal.addCallObserver(new MyCallCtlInCallObserver2(null));
System.out.println(terminal.getName());
} catch (Exception excp) {
System.out.println("Can't get Terminal: " + excp.toString());
System.exit(0);
}
}
}


Vijay Rawat

Posts: 1
Nickname: vrawat78
Registered: Jun, 2007

Re: a jtapi problem Posted: May 31, 2007 11:22 PM
Reply to this message Reply
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

Thanks and Regards
Vijay Rawat

Flat View: This topic has 1 reply on 1 page
Topic: a jtapi problem Previous Topic   Next Topic Topic: DataVision

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use