Cisco Call Manager 3.3, CTI route point, JTAPI Application
Kumkum Bagchi <[email protected]>
| Newsgroups | gmane.comp.java.sun.jtapi |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
Hi
I am trying to build an application where all calls coming to the call
manager gets forwaded to one terminal (Say Terminal F ) and the JTAPI
applictaion is observing this terminal for incoming call events. I was
able to do "the all call forwarding to one terminal" by creating a CTI
route point and this works for calls coming from IP phones registered with
the PBX and from any PSTN number. Eventually I want this terminal F (where
all calls are being forwarded ) not to ring but execute some application
logic based on the callerTn and callingTN. To be precise what I want to
accomplish now is the following
1. Get the caller id of the original caller
2. Get the caller id of the called party
3. make terminal F not to ring.
My first question is this the best way to do it - i am not sure if this is
a viable solution or not? And if it is the - any hint how I can get it
implemented? Is there a way I can observe the Directory number used in the
CTI Route point/or the CTI route point itself?
Here is the code I am using so far - which is a modified version of JTAPI
sample makecall. I am very new to the technology - so any kind of tips is
greatly appreciated.
Thanks in advance.
Kumkum.
--CODE
--File:makecall.java
import java.util.*;
import javax.telephony.*;
import javax.telephony.events.*;
import com.cisco.cti.util.Condition;
public class makecall extends TraceWindow implements ProviderObserver
{
Vector actors = new Vector ();
Condition conditionInService = new Condition ();
Provider provider;
public makecall ( String [] args ) {
super ( "makecall" + ": "+ new CiscoJtapiVersion());
try {
println ( "Initializing Jtapi" );
int curArg = 0;
String providerName = args[curArg++];
String login = args[curArg++];
String passwd = args[curArg++];
int actionDelayMillis = Integer.parseInt ( args
[curArg++] );
String src = null;
String dest = null;
JtapiPeer peer = JtapiPeerFactory.getJtapiPeer (
null );
if ( curArg < args.length ) {
String providerString = providerName
+ ";login=" + login + ";passwd=" + passwd;
println ( "Opening " + providerString
+ "...\n" );
provider = peer.getProvider (
providerString );
provider.addObserver ( this );
conditionInService.waitTrue ();
Address observedaddr = null;
Terminal observedTerm = null;
try
{
observedaddr = provider.getAddress
("3596"); //forwarding terminal
System.out.println ( "Got
observedaddr ");
Terminal[] terminals =
observedaddr.getTerminals();
if (terminals == null)
{
System.out.println("No
Terminals on Address.");
System.exit(0);
}
observedTerm = terminals[0];
System.out.println("Terminals
available on Address.");
}
catch (Exception excp)
{
System.out.println("Can't get
Terminal: " + excp.toString());
System.exit(0);
}
observedTerm.addCallObserver(new
MyInCallObserver());
}
}
catch ( Exception e )
{
println ( "Caught exception " + e );
}
}
public void dispose () {
println ( "Stopping actors" );
Enumeration e = actors.elements ();
while ( e.hasMoreElements () ) {
Actor actor = (Actor) e.nextElement ();
actor.dispose ();
}
}
public static void main ( String [] args )
{
if ( args.length < 6 ) {
System.out.println ( "Usage: makecall <server>
<login> <password> <delay> <origin> <destination> ..." );
System.exit ( 1 );
}
new makecall ( args );
}
public void providerChangedEvent ( ProvEv [] eventList ) {
if ( eventList != null ) {
for ( int i = 0; i < eventList.length; i++ )
{
if ( eventList[i] instanceof
ProvInServiceEv ) {
conditionInService.set ();
}
}
}
}
}
File:MyInCallObserver.java
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;
}
}
}
}
}
}
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JTAPI-INTEREST". For general help, send email to
[email protected] and include in the body of the message "help".