Solved

Problems on JTAPI

Posted on 2000-05-09
7
831 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

627 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