java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--javax.telephony.InvalidArgumentException
public InvalidArgumentException()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1163]Places a telephone call
By Anonymous on 2004/12/03 00:47:19 Rate
import javax.telephony.*;
import javax.telephony.events.*;
//import MyOutCallObserver;
public class Outcall {
public static final void main ( String args [ ] ) {
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 ) ;
}
Address origaddr = null;
Terminal origterm = null;
try {
origaddr = myprovider.getAddress ( "0" ) ;
Terminal [ ] terminals = origaddr.getTerminals ( ) ;
if ( terminals == null ) {
System.out.println ( "No Terminals on Address." ) ;
System.exit ( 0 ) ;
}
origterm = terminals [ 0 ] ;
} catch ( Exception excp ) {
System.out.println ( "no terminal: "+excp.toString ( ) ) ;
System.exit ( 0 ) ;
// Handle exceptions;
}
Call mycall = null;
try {
mycall = myprovider.createCall ( ) ;
mycall.addObserver ( new MyOutCallObserver ( ) ) ;
} catch ( Exception excp ) {
// Handle exceptions
}
try {
Connection c [ ] = mycall.connect ( origterm, origaddr, "25551212" ) ;
} catch ( Exception excp ) {
// Handle all Exceptions
}
}
}
class MyOutCallObserver implements CallObserver {
public void callChangedEvent ( CallEv [ ] evlist ) {
for ( int i = 0; i < evlist.length; i++ ) {
if ( evlist [ i ] instanceof ConnEv ) {
String name = null;
try {
Connection connection = ( ( ConnEv ) evlist [ i ] ) .getConnection ( ) ;
Address addr = connection.getAddress ( ) ;
name = addr.getName ( ) ;
} catch ( Exception excp ) {
// Handle Exceptions
}
String msg = "Connection to Address: " + name + " is ";
if ( evlist [ i ] .getID ( ) == ConnAlertingEv.ID ) {
System.out.println ( msg + "ALERTING" ) ;
}
else if ( evlist [ i ] .getID ( ) == ConnInProgressEv.ID ) {
System.out.println ( msg + "INPROGRESS" ) ;
}
else if ( evlist [ i ] .getID ( ) == ConnConnectedEv.ID ) {
System.out.println ( msg + "CONNECTED" ) ;
}
else if ( evlist [ i ] .getID ( ) == ConnDisconnectedEv.ID ) {
System.out.println ( msg + "DISCONNECTED" ) ;
}
}
}
}
}
[1980]
By Anonymous on 2008/09/03 12:43:23 Rate
have u solved this can't get terminal error so far please?
if so email to me
my email address is
ashuhawey20@gmail.com
Alemtsehay from Ethiopia
public InvalidArgumentException(java.lang.String s)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1334]Recevie incoming call
By bilgincetin { at } yahoo { dot } com on 2005/03/09 17:48:18 Rate
i recieve the error below:
"Can't get Terminal: javax.telephony.InvalidArgumentException"
could you tell me what I should write as a parameter to this method- > myprovider.getTerminal ( "2180916" ) .by the way i use a Voice modem
here is my code snippet:
----------------------------------
import javax.telephony.Provider;
import javax.telephony.JtapiPeer;
import javax.telephony.JtapiPeerFactory;
import javax.telephony.*;
import javax.telephony.events.*;
import javax.telephony.callcontrol.*;
import javax.telephony.callcontrol.events.*;
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 ) {
// Handle exceptions.
}
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" ) ;
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 ( ) == CallCtlTermConnDroppedEv.ID ) {
System.out.println ( msg + "DROPPED" ) ;
}
}
}
}
}
// ----------------------------------------------------------
public class CallCtlIncall {
static String [ ] mypro;
public static final void main ( String args [ ] ) {
Provider myprovider = null;
try {
JtapiPeer peer = JtapiPeerFactory.getJtapiPeer ( "net.xtapi.XJtapiPeer" ) ;
myprovider = peer.getProvider ( "MSTAPI" ) ;
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 ( "2180916" ) ;
terminal.addCallObserver ( new MyCallCtlInCallObserver ( ) ) ;
} catch ( Exception excp ) {
System.out.println ( "Can't get Terminal: " + excp.toString ( ) ) ;
System.exit ( 0 ) ;
}
}
}