Joerg Wesely | Hi, I'd like to write a program that registers a CTI route point, accepts incoming calls and plays a message. I could register the CTI Route point, but I think the little bit that accepts the call is missing. If I call the RP, I receive a CallActiveEv and a ConnConnectedEv (that seems to indicate that the phone the call is started from is now connected), but there is no event I can get a RTPHandle or so from. After about a second, the call is disconnected and I get a busy tone on my phone. Any Idea what's wrong or missing in the code below? Or does anyone has some example code for me? Thanks in advance Jörg public class ConditionalForwarder implements ProviderObserver, CiscoTerminalObserver, CiscoAddressObserver, CallObserver,MediaCallObserver, CallControlTerminalObserver, PhoneTerminalObserver {
static private Log log = LogFactory.getLog(ConditionalForwarder.class);
Condition providerInService = new Condition(); Condition terminalInService = new Condition(); Condition addressInService = new Condition();
CiscoProvider provider; CiscoRouteTerminal terminal; CiscoAddress address;
public ConditionalForwarder(String host, String userid, String password, String deviceName) {
String providerString= host + ";login=" + userid + ";passwd=" + password; try { JtapiPeer peer = JtapiPeerFactory.getJtapiPeer ( null ); provider = (CiscoProvider)peer.getProvider(providerString); provider.addObserver(this); providerInService.waitTrue(); terminal = (CiscoRouteTerminal)provider.getTerminal(deviceName); CiscoMediaCapability[] cap = {new CiscoG711MediaCapability()}; terminal.register(cap,CiscoRouteTerminal.DYNAMIC_MEDIA_REGISTRATION); terminal.addObserver(this); terminal.addCallObserver(this); address = (CiscoAddress)terminal.getAddresses()[0]; address.addObserver(this); address.addCallObserver(this); terminalInService.waitTrue(); addressInService.waitTrue(); log.info("Initialization done."); } catch (Exception e) { e.printStackTrace(); } }
public void providerChangedEvent(ProvEv[] eventList) { if ( eventList != null ) { for ( int i = 0; i < eventList.length; i++ ) { log.debug(eventList.getClass().getCanonicalName()); if ( eventList instanceof ProvInServiceEv ) { providerInService.set(); return; } } } }
public void callChangedEvent(CallEv[] eventList) { if ( eventList != null ) { for ( int i = 0; i < eventList.length; i++ ) { CallEv event = eventList; log.debug("CALL: " + event.getClass().getCanonicalName()); CiscoCall call = (CiscoCall)event.getCall(); Connection[] connections = call.getConnections(); for(int j=0; i<connections.length;j++) { log.info(connections.getAddress().getName() + " State: " + getStateName(connections.getState())); } } } }
public void addressChangedEvent(AddrEv[] eventList) { if ( eventList != null ) { for ( int i = 0; i < eventList.length; i++ ) { log.debug("ADDRESS: " + eventList.getClass().getCanonicalName()); if ( eventList instanceof CiscoAddrInServiceEv ) { addressInService.set(); return; } } } }
public void terminalChangedEvent(TermEv[] eventList) { if ( eventList != null ) { for ( int i = 0; i < eventList.length; i++ ) { log.debug("TERMINAL: " + eventList.getClass().getCanonicalName()); if ( eventList instanceof CiscoTermInServiceEv ) { terminalInService.set(); return; } } } }
public static String getStateName(int state) { switch(state) { case (Connection.ALERTING) : return "ALERTING"; case (Connection.CONNECTED) : return "CONNECTED"; case (Connection.DISCONNECTED) : return "DISCONNECTED"; case (Connection.FAILED) : return "FAILED"; case (Connection.IDLE) : return "IDLE"; case (Connection.INPROGRESS) : return "INPROGRESS"; case (Connection.UNKNOWN) : return "UNKNOWN"; default : return "OTHER"; } }
public static void main(String[] args) {
new ConditionalForwarder("10.129.32.20", "condFwd", "XXXX","CONFWD01"); }
} |
| Please sign in to flag this as inappropriate. |