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
Solved

Problems on JTAPI

Posted on 2000-05-09
7
787 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Facing this issue for maven proxy setting 2 20
Java Restore security prompts not working 10 53
Crystal Reports Licensing Questions 4 34
hashmap order 17 36
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

808 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