Solved

Problems on JTAPI

Posted on 2000-05-09
7
760 Views
Last Modified: 2008-02-20
I have downloaded JTAPI 1.3 specifications in form of Java files and Classes from Sun's Java Telephony download page.

How can I proceed with JTAPI?
0
Comment
Question by:sghosh092199
7 Comments
 
LVL 3

Accepted Solution

by:
terajiv earned 73 total points
ID: 2795351
Hi sghosh,

Download the Documentation from Java.sun.com There u will get one Example or other wise I will pest it here only...Just referm to that and Apply ur logic for next development....
Oh yes Change the phone Numbers and make sure that u have got service Provider..

Rajiv
0
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2797645
0
 
LVL 3

Expert Comment

by:terajiv
ID: 2798653
Outgoing Telephone Call Example
The following code example places a telephone call using the core Call.connect() method. It, however, looks for the states provided by the Call Control package.

import javax.telephony.*;
import javax.telephony.events.*;

/*
 * The MyOutCallObserver class implements the CallObserver
 * interface and receives all events associated with the Call.
 */
 
public 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");
        }
      }  
    }
  }
}


         ------------------------------------------------------


import javax.telephony.*;
import javax.telephony.events.*;
import MyOutCallObserver;


/*
 * Places a telephone call from 476111 to 5551212
 */
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(null);
      myprovider = peer.getProvider(null);
    } 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("4761111");
 
      /* 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) {
      // 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, "5551212");
    } catch (Exception excp) {
      // Handle all Exceptions
    }
  }
}





Incoming Telephone Call Example
The following code example illustrates how an application answers a Call at a particular Terminal. It shows how applications accept calls when (and if) offered. This code example greatly resembles the core InCall code example.

import javax.telephony.*;
import javax.telephony.events.*;

import javax.telephony.*;
import javax.telephony.events.*;

/*
 * The MyInCallObserver class implements the CallObserver and
 * recieves all Call-related events.
 */
 
public 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");
        }
      }  
    }
  }
}

            ----------------------------------------------------

import javax.telephony.*;
import javax.telephony.events.*;
import MyInCallObserver;

/*
 * Create a provider and monitor a particular terminal for an incoming call.
 */
public class Incall {
 
  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(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 terminal = myprovider.getTerminal("4761111");
      terminal.addCallObserver(new MyInCallObserver());
    } catch (Exception excp) {
      System.out.println("Can't get Terminal: " + excp.toString());
      System.exit(0);
  }
  }
}
U can make use of it...
Rajiv

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:akokchai
ID: 2866112
HI, Rajiv and everybody. I am very intesting in java-hardware(JTAPI, Comm & etc). Can you share you experience and me???

My email is axilian@sinamail.com
0
 
LVL 3

Expert Comment

by:terajiv
ID: 2872499
What expr. u want? If u have any doubts just ask.... or rather why dont u join java's JTAPI Interest group... U can get Expr from around 20/30 experts...
So better u join that If u want from me Im not saying no to that... Just ask any queries...

What about the Points?
:::)))))
0
 
LVL 1

Expert Comment

by:akokchai
ID: 2896922
 Hi terajiv, I am akokchai. Can you tell which JTAPI interest group can be enjoyed. Autually, I hope to know what product be designed in JTAPI(or TAPI...). Do you have any info(website) of them. Tell me please.


Have a nice day.bye.
0
 

Expert Comment

by:snehalathamomidi
ID: 5495064
Hi Terajiv and others,


The programs given by Mr.Terajiv, (beleive, downloads from Java.sun.com)which are when executed will give peer and provider problems.

This is about providing info and my doubt also. Please do the needful.

Found solution partially from JTAPI Java.sun.com Forums.

1. JTAPI implementation CallPath from IBM is downloaded.

I tried “MyPhone” program posted by Mr. Keane in the JTAPI Java.sun.com Forum..
================MyPhone.java=============
import javax.telephony.*;
import javax.telephony.events.*;
import javax.telephony.callcontrol.*;
import javax.telephony.callcontrol.events.*;
import MyCallCtlInCallObserver;


public class MyPhone {
 
public static final void main(String[] args){

      Provider myprovider = null;
      try {
            System.out.println("Initializing Peer...");
JtapiPeer peer = JtapiPeerFactory.getJtapiPeer("com.ibm.telephony.callpath.CSAJtapiPeer");                               System.out.println("Peer Initialized.");
            System.out.println("Peer Name:" + peer.getName ());

//List of services
            String srvLst[] = peer.getServices();
            System.out.println("No of Services:" +       srvLst.length);
            myprovider = peer.getProvider("foo.foobar.com;login=blah;passwd=blah");
            //myprovider = peer.getProvider(null);
            }catch(ProviderUnavailableException puExcp){
            System.out.println(puExcp.getCause() + " : " +
            puExcp.toString());
            }catch(Exception excp){
// Handle exceptions
System.out.println("Excp:" + excp);
}
}
}


I am using JTAPI(IBM CallPath) and the class path is set.

I tried this with a modem connection.

When executed the program found the following at the command prompt…

Initializing Peer...
Peer Initialized.
Peer Name:com.ibm.telephony.callpath.CSAJtapiPeer
No of Services:0
162 : javax.telephony.ProviderUnavailableException

Did any one of you here have any other way to detect call connection?

I tried all the possibilities specified by various friends from the forum, but same provider problem is persisting.

Is there anyone with any new suggestion to overcome this problem?

Please reply back.

Thanking you.

With Best Wishes,
Sneha.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
network + 7 80
reasons why a "inside Menu" would not appear for a web server 6 56
base64 decode encode 12 122
netstat -ano | find "8000" and taskkill /f /pid 2984 3 38
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now