KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > telephony > InvalidArgumentException

javax.telephony
Class InvalidArgumentException

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; 
  
  
  
 /* 
  * Places a telephone call from 2476111 to 25551212 
  */
 
 public class Outcall  {  
   
   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 ) ; 
      }  
   
    /* 
     * We need to get the appropriate objects associated with the 
     * originating side of the telephone call. We ask the Address for a list 
     * of Terminals on it and arbitrarily choose one. 
     */
 
     Address origaddr = null; 
     Terminal origterm = null; 
     try  {  
       origaddr = myprovider.getAddress ( "0" ) ; 
   
       /* Just get some Terminal on this Address */ 
       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; 
      }  
   
   
     /* 
      * Create the telephone call object and add an observer. 
      */
 
     Call mycall = null; 
     try  {  
       mycall = myprovider.createCall (  ) ; 
       mycall.addObserver ( new MyOutCallObserver (  )  ) ; 
      }  catch  ( Exception excp )   {  
       // Handle exceptions 
      }  
   
     /* 
      * Place the telephone call. 
      */
 
     try  {  
       Connection c [  ]  = mycall.connect ( origterm, origaddr, "25551212" ) ; 
      }  catch  ( Exception excp )   {  
       // Handle all Exceptions 
      }  
    }  
  }  
  
  
  
  
 /* 
  * The MyOutCallObserver class implements the CallObserver 
  * interface and receives all events associated with the Call. 
  */
 
   
  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.*; 
  
  
 /* 
  * The MyCallCtlInCallObserver class implements the CallControlCallObserver and 
  * recieves all Call-related 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" ) ; 
  
  
           /* 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 (  )  == CallCtlTermConnDroppedEv.ID )   {  
           System.out.println ( msg + "DROPPED" ) ; 
          }  
        }  
      }  
    }  
  }  
  
  
 // ---------------------------------------------------------- 
  
  
  
  
  
  
 /* 
  * Create a provider and monitor a particular terminal for an incoming call. 
  */
 
 public class CallCtlIncall  {  
          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" ) ; 
       mypro=peer.getServices (  ) ; 
      }  catch  ( Exception excp )   {  
       System.out.println ( "Can't get Provider: " + excp.toString (  )  ) ; 
                          System.out.println ( mypro ) ; 
       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 ( "2180916" ) ; 
       terminal.addCallObserver ( new MyCallCtlInCallObserver (  )  ) ; 
      }  catch  ( Exception excp )   {  
       System.out.println ( "Can't get Terminal: " + excp.toString (  )  ) ; 
       System.exit ( 0 ) ; 
      }  
    }  
  } 

Popular Tags