Skip to main content

alphaWorks  >  Forums  >  J323 Engine  >  developerWorks

Exception ("Incall.java")    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
Permlink Replies: 2 - Pages: 1 - Last Post: Jun 25, 2006 8:30 AM Last Post By: Maryam Threads: [ Previous | Next ]
Amir
Exception ("Incall.java")
Posted: May 24, 2005 02:54:26 AM
Click to report abuse...   Click to reply to this thread Reply
we compile this code and it is compiled successfully but when it is run an exception
occurs, as shown in the output.here 4580168 is our home phone number.

***********************************************************************************************
source code
***********************************************************************************************

import javax.telephony.*;
import javax.telephony.events.*;
import javax.telephony.*;
import javax.telephony.events.*;
import java.net.*;
import javax.telephony.*;
import javax.telephony.events.*;

/*
* The MyInCallObserver class implements the CallObserver and
* recieves all Call-related events.
*/

class MyInCallObserver 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.
}

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

/*
* Create a provider and monitor a particular terminal for an incoming call.
*/
public class Incall1 {

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");
//JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
myprovider = peer.getProvider(null);
} 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 add1 = myprovider.getTerminal("4580168");
add1.addCallObserver(new MyInCallObserver());

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

**********************************************************************************************
output
**********************************************************************************************

C:\active>java Incall
IBM J323 Engine v5.0.0
(C) Copyright IBM Corporation, 1996-2003. All rights reserved.
Setting login to 'shafaat haider'
Can't get Terminal: javax.telephony.InvalidArgumentException: unknown terminal
4580168

C:\active>



Posts: 1
Registered: Oct 23, 2005 02:35:49 PM
Re: Exception ("Incall.java")
Posted: Oct 23, 2005 02:37:57 PM   in response to: Amir in response to: Amir 's post
Click to report abuse...   Click to reply to this thread Reply
before calling Terminal add1 = myprovider.getTerminal("4580168");

you must get the list of available terminals (myprovider.getTerminals()) and check if it contains your 4580168 terminal.
Maryam

Posts: 1
Registered: Jun 25, 2006 08:24:00 AM
Re: Exception ("Incall.java")
Posted: Jun 25, 2006 08:30:44 AM   in response to: in response to: 's post
Click to report abuse...   Click to reply to this thread Reply
Hi ,

I have the same problem using Incall code
and when I get list of teminals it is just one terminal available :

I use the code below checking my available terminals :

Terminal[] terminals = null;
try
{
//address = myprovider.getAddress("2252709");
//Thread.sleep(1000);
terminals = myprovider.getTerminals();
System.out.println("" + terminals.length);
System.out.println("" + terminals[0]);

}
/****************************************/

and it shows me the name -com.ibm.telephony.mm.MM_Terminal { LOCALTERM }- as terminal what can I do to active the telephone number that modem is connected to as my termial .

Point your RSS reader here for a feed of the latest messages in all forums