wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes To get a call using JTAPI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "To get a call using JTAPI" Watch "To get a call using JTAPI" New topic
Author

To get a call using JTAPI

yspl india
Greenhorn

Joined: Aug 08, 2005
Posts: 8
Hello Sir/Madam,
I am venkateshwaran very new to JTAPI. I am trying to get a call using JTAPI.I have downloaded JTAPI 1.4,JMF 2.1.1e,XTAPI.jar,MSTAPI.jar and the corresponding classpath's are set.

I am getting the error as

Can't get Terminal: javax.telephony.InValidArgumentException.

My Source Code is:

import javax.telephony.*;
import javax.telephony.events.*;
import javax.telephony.callcontrol.*;
import javax.telephony.callcontrol.events.*;
import javax.telephony.*;
import javax.telephony.Provider;
import javax.telephony.JtapiPeer;
import javax.telephony.JtapiPeerFactory;
/*
* The MyCallCtlInCallObserver class implements the CallControlCallObserver and
* recieves all Call-related events.
*/
public class InCallXM{

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");
} catch (Exception excp) {
System.out.println("Can't get Provider: " + excp.toString());
System.exit(0);
}

/*
* Get the terminal we wish to monitor and add a call observer to that
* Terminal. This will place a call observer on all call which come to
* that terminal. We are assuming that Terminals are named after some
* primary telephone number on them.
*/

try {
Terminal terminal = myprovider.getTerminal("52068941");

//52068941 is the phone no which is connected to the modem

terminal.addCallObserver(new MyCallCtlInCallObserver());
System.out.println("aaaaa");

} catch (Exception excp) {
System.out.println("Can't get Terminal: " + excp.toString());
System.exit(0);
}

}

}





class MyCallCtlInCallObserver implements CallControlCallObserver {

public void callChangedEvent(CallEv[] evlist) {
for (int i = 0; i < evlist.length; i++) {

if (evlist[i] instanceof TermConnEv) {
TerminalConnection termconn = null;
String name = null;
try {
TermConnEv tcev = (TermConnEv)evlist[i];
Terminal term = termconn.getTerminal();
termconn = tcev.getTerminalConnection();
name = term.getName();
} catch (Exception excp) { }

String msg = "TerminalConnection to Terminal: " + name + " is ";

if (evlist[i].getID() == CallCtlTermConnTalkingEv.ID) {
System.out.println(msg + "TALKING");
}
else if (evlist[i].getID() == CallCtlTermConnRingingEv.ID) {
System.out.println(msg + "RINGING");

/* Answer the telephone Call using "inner class" thread */

try {
final TerminalConnection _tc = termconn;
Runnable r = new Runnable() {
public void run() {
try{
_tc.answer();
} catch (Exception excp){ }
};
};
Thread T = new Thread(r);
T.start();
} catch (Exception excp) { }
}
else if (evlist[i].getID() == CallCtlTermConnDroppedEv.ID) {
System.out.println(msg + "DROPPED");
}
}
}
}
}

/*
* Create a provider and monitor a particular terminal for an incoming call.
*/
Please give me solution as i am struck up with this for past 20 days.

Thanks in Advance,
Venkateshwaran.
[ September 05, 2005: Message edited by: yspl india ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To get a call using JTAPI