Hai,
I am shobana i am very new to JTAPI.I am trying to make an Incall using JTAPI for which i have installed JTAPI 1.4,JMF2.1.e and J323 engine.The erroe which i get is:
Can't get Terminal: javax.telephony.InvalidArgumentException: unknown terminal 52317702
where 52317702 is the phone no which is connected to the modem of the computer.
The source code which i have used is:
import javax.telephony.*;
import javax.telephony.events.*;
/*
* Create a provider and monitor a particular terminal for an incoming call.
*/
public class aInCall {
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("com.ibm.telephony.mm.MM_JtapiPeer");
myprovider = peer.getProvider("H.323 Endpoint;login=52317702");
} 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("52317702");
terminal.addCallObserver(new aInCallObserver());
} catch (Exception excp) {
System.out.println("Can't get Terminal: " + excp.toString());
System.exit(0);
}
}
}
class aInCallObserver implements CallObserver {
public void callChangedEvent(CallEv[] evlist) {
TerminalConnection termconn;
String name;
for (int i = 0; i < evlist.length; i++) {
if (evlist[i] instanceof TermConnEv) {
termconn = null;
name = null;
try {
TermConnEv tcev = (TermConnEv)evlist[i];
Terminal term = termconn.getTerminal();
termconn = tcev.getTerminalConnection();
name = term.getName();
} catch (Exception excp) {
// Handle exceptions.
System.out.println("Error on event "+excp);
}
String msg = "TerminalConnection to Terminal: " + name + " is ";
if (evlist[i].getID() == TermConnActiveEv.ID) {
System.out.println(msg + "ACTIVE");
}
else if (evlist[i].getID() == TermConnRingingEv.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){
// handle answer exceptions
}
};
};
Thread T = new Thread(r);
T.start();
} catch (Exception excp) {
// Handle Exceptions;
}
} else if (evlist[i].getID() == TermConnDroppedEv.ID) {
System.out.println(msg + "DROPPED");
}
}
}
}
}
Please give me a solution for this i am trying to find a solution for this for past 10 days.I need to finish it within 2 days.If anybody knows the solution please drop me.Thanks in advance.
Regards,
J.Shobana.