Solved

Problems on JTAPI

Posted on 2000-05-09
7
734 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

708 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

15 Experts available now in Live!

Get 1:1 Help Now