com.genesyslab.ail
Class PsdkVoiceBridge

java.lang.Object
  extended by com.genesyslab.ail.PsdkVoiceBridge

public class PsdkVoiceBridge
extends java.lang.Object

Retrieves the TServerProtocol class instance associated with a given switch.

A switch is considered connected if the Connections tab of an AIL application object's properties defined in the Configuration Layer contains a T-Server connected to this switch.

To track switch connections and disconnections, create and add a ServiceListener to the AilFactory to get events for status changes on ServiceStatus objects of type Telephony. You can get the Switch instance through the corresponding ServiceStatus instance, as shown here:

public class SimpleServiceListener implements ServiceListener {
    AilFactory myFactory;
    public void SimpleServiceListener(AilFactory _myFactory) {
        myFactory = _myFactory ;
        myFactory.addServiceListener(ServiceStatus.Type.TELEPHONY,this);
    }
    public void serviceStatusChanged(ServiceStatus.Type service_type, java.lang.String service_name, ServiceStatus.Status service_status) {
        // handle Service.Status on disconnections
        if(service_status == ServiceStatus.Status.OFF) {
            //...
            ServiceStatus srv_status = myFactory.getServiceStatus(service_name);
            Switch the_switch = srv_status.mSwitch ;
            //...
        }
    }
}


Nested Class Summary
static interface PsdkVoiceBridge.Listener
          This listener interface allows you to get messages that the AIL receives through its TServerProtocol instance.
 
Method Summary
static void addTServerListener(Switch sw, PsdkVoiceBridge.Listener listener)
          Adds a listener for the TServerProtocol instance associated with this switch.
static com.genesyslab.platform.voice.protocol.TServerProtocol getTServer(Switch sw)
          Returns the TServerProtocol instance associated with this switch.
static void removeTServerListener(Switch sw, PsdkVoiceBridge.Listener listener)
          Removes a listener previously added.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTServer

public static com.genesyslab.platform.voice.protocol.TServerProtocol getTServer(Switch sw)
                                                                         throws TelephonyServiceException

Returns the TServerProtocol instance associated with this switch.
Note: According to the TServerProtocol status, requests sent the T-Server may not be processed. In addition, Genesys recommends that you do not issue actions that could interfere with the AIL. In particular, restrict your use of TServerProtocol to non-disruptive requests such as RequestPrivateService, RequestDistributeUserEvent, RequestMonitorNextCall, or other features that the AIL does not use.

The following code snippet shows how to send the RequestMonitorNextCall message on a Dn object:

TServerProtocol tsp = PsdkVoiceBridge.getTServer( dn.getSwitch() );
Message message = RequestMonitorNextCall.create( dn.getName(), agentDn,
        MonitorNextCallType.AllCalls, reasons, extensions );
tsp.send( message );

Parameters:
sw - Name of a connected switch.
Returns:
A TServerProtocol instance.
Throws:
TelephonyServiceException - if the switch is not connected (the switch is not referenced in the Connections tab of the AIL application object defined in the Configuration Layer).
TelephonyServiceException

addTServerListener

public static void addTServerListener(Switch sw,
                                      PsdkVoiceBridge.Listener listener)
                               throws TelephonyServiceException

Adds a listener for the TServerProtocol instance associated with this switch.

If the switch disconnects, the listener reference set for the corresponding TServerProtocol instance is lost and you must register for this listener again. To get notified of disconnections, implement a ServiceListener class.

As the AIL calls the listener from its internal thread that reads the events from the TServerProtocol class, you should not implement event processing in the handle() method. When you implement a Listener instance, Genesys recommends using threads to process events, as shown in the following code snippet:

For example, create a handler to dispatch the Message in a queue:

QueuedExecutor mQueue = new QueuedExecutor();

PsdkVoiceBridge.Listener mListener = new PsdkVoiceBridge.Listener() {
        public void handle( final Message message ) {
            mQueue.execute( new Runnable() {
                public void run() {
                    myHandler( message );
                }
            } );
        }
    };

PsdkVoiceBridge.addTServerListener( switch, mListener );

//...

public void myHandler( Message message ) {
...
}

Throws:
TelephonyServiceException - if the switch is not connected (the switch is not referenced in the Connections tab of the AIL application object defined in the Configuration Layer).

removeTServerListener

public static void removeTServerListener(Switch sw,
                                         PsdkVoiceBridge.Listener listener)
                                  throws TelephonyServiceException

Removes a listener previously added. Note that if the switch disconnects from the application, the listener reference is lost and you do not need to remove your listener.

Throws:
TelephonyServiceException - if the switch is not connected (the switch is not referenced in the Connections tab of the AIL application object defined in the Configuration Layer).