Search code examples
javaciscoconferencejtapicisco-jtapi

How to use cBarge (Barge) to create conference with JTApi


We have 2 cisco phones: one for call manager and another for his superviser.

We need to create a conference when the manager answers and put the supervisor's phone on mute. We are trying to achieve it using JTApi: wait for event TermConnActiveEv, then trying to create conference.

Here is the code sample.

if (callEv instanceof TermConnActiveEv) {
CiscoCall thisCall = (CiscoCall) callEv.getCall();
TerminalConnection connection = ((TermConnActiveEv) callEv).getTerminalConnection();

if (thisCall.getState() != Call.ACTIVE)
{
    System.out.println("call is not active");
    return;
}
try {
    CiscoCall newCall = (CiscoCall) provider.createCall();
    newCall.consult(connection);
    newCall.conference(thisCall);

    ....

However, PreConditionException is thrown. What are we doing wrong?


Solution

  • You don't need to use Barge to create a conference.

    You can try to do something like that:

    if (callEv instanceof TermConnActiveEv) {
        CiscoCall thisCall = (CiscoCall) callEv.getCall();
        TerminalConnection tc = thisCall.getConferenceController();
        Connection[] connections = thisCall.getConnections();
    
        TerminalConnection[] tcs = connections[0].getTerminalConnections();
        if (tcs.length > 0 && tc == null) {
            tc = tcs[0];
        }
    
        if (tc == null) {
            System.out.println("Conference controller is null.");
        } else {
            try {
                Call call = provider.createCall();
                call.connect(thisAddress.getTerminals()[0], thisAddress, superVisorAddress);
                thisCall.conference(call);
            } catch (Exception ex) {
                System.out.println("Exception " + ex);
                ex.printStackTrace();
            }
        }
    }
    

    To set mute you can use:

    ((CiscoTerminal)termConnections[i].getTerminal().sendData("<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"URL=\"Key:Mute\"/></CiscoIPPhoneExecute>");
    

    Before the application can make use of this feature, it must add TerminalObserver on the terminal.