Genesys CTI User Forum

Genesys CTI User Forum => Genesys-related Development => Topic started by: apu321X on June 30, 2017, 11:46:56 PM

Title: Is it possible to filter call events by parameters or data in specific?
Post by: apu321X on June 30, 2017, 11:46:56 PM
Hello everyone ,
I am doing a program where I am only taking the call culmination events. I just want to make the filter by a certain parameter. It is possible to filter by the campaign, campaign group or queue or other information with the objective to discriminate some unnecessary events. Is this possible?

Here is my code fragment:


[code]


package com.genesys.ivrvox.manager;

import com.genesys.ivrvox.conexion.Conexion;
import com.genesyslab.platform.commons.collections.KeyValueCollection;
import com.genesyslab.platform.commons.protocol.Message;
import com.genesyslab.platform.commons.protocol.MessageHandler;
import com.genesyslab.platform.commons.protocol.ProtocolException;
import com.genesyslab.platform.commons.protocol.RegistrationException;
import com.genesyslab.platform.configuration.protocol.confserver.requests.objects.RequestReadObjects;
import com.genesyslab.platform.routing.protocol.routingserver.requests.RequestNotify;
import com.genesyslab.platform.voice.protocol.TServerProtocol;
import com.genesyslab.platform.voice.protocol.tserver.events.EventEstablished;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author Home
*/
public class ManagerHandleEvent implements Runnable {

    private TServerProtocol tserverProtocol;

    public ManagerHandleEvent() {
        try {
            tserverProtocol = Conexion.tServerProtocol();
        } catch (IllegalStateException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void run() {
        try {
            tserverProtocol.setMessageHandler(new MessageHandler() {

                public void onMessage(Message msg) {
                    if (msg instanceof EventEstablished) {
                        EventEstablished eventStablished = (EventEstablished) msg;
                        System.out.println(eventStablished.getUserData());
                        //KeyValueCollection keyValueCollection =eventStablished.getUserData();
                        //keyValueCollection.
                    }
                }
            });
            tserverProtocol.open();
            RequestNotify request = RequestNotify.create();
            tserverProtocol.send(request);
        } catch (RegistrationException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ProtocolException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalStateException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}


[/code]


Title: Re: Is it possible to filter call events by parameters or data in specific?
Post by: cavagnaro on July 01, 2017, 11:34:49 AM
You are listening to an Event, all of them, you can't filter what to lister or not.
After you listen you decide based maybe on Attach Data of that Call but not before.
Title: Re: Is it possible to filter call events by parameters or data in specific?
Post by: PeteHoyle on July 03, 2017, 08:13:41 AM
You will only receive Events for the DN(s) you have registered for.
You can't filter these events on Campaign, Campaign Group or Queue but you can decide which events you are sent by TServer by using the EventMask

[code]RequestSetInputMask req = RequestSetInputMask.create();
EventMask mask = new EventMask();
mask.set(EventPrimaryChanged.ID);
mask.set(EventRegistered.ID);
mask.set(EventDialing.ID);
mask.set(EventUnregistered.ID);
mask.set(EventEstablished.ID);
mask.set(EventReleased.ID);
mask.set(EventPartyChanged.ID);
mask.set(EventAbandoned.ID);
req.setInputMask(mask);
Message m;
log.info("InputMask " + mask.toString());
m = mProtocolManager.getProtocol(ts_name).request(req);[/code]
Title: Re: Is it possible to filter call events by parameters or data in specific?
Post by: apu321X on July 03, 2017, 06:05:19 PM
thanks for answering ,
My code would look like this:
[code]
  public void run() {
        try {
            tserverProtocol.setMessageHandler(new MessageHandler() {
                public void onMessage(Message msg) {
                    System.out.println("msg => " + msg.toString());
                    /*if (msg instanceof EventEstablished) {
                    EventEstablished eventStablished = (EventEstablished) msg;
                    System.out.println("--------------------------------------------");
                    System.out.println(eventStablished.toString());
                    System.out.println(eventStablished.getUserData());
                    System.out.println("--------------------------------------------");
                    }*/
                }
            });
            tserverProtocol.open();
            RequestSetInputMask request = RequestSetInputMask.create();
            EventMask mask = new EventMask();
            mask.set(EventEstablished.ID);
            mask.set(EventRinging.ID);
            mask.set(EventDialing.ID);
            mask.set(EventAbandoned.ID);
            mask.setAll();
            System.out.println("InputMask ---->  " + mask.toString());
            request.setInputMask(mask);
            tserverProtocol.send(request);


        } catch (RegistrationException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ProtocolException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalStateException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(ManagerHandleEvent.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

[/code]
As a result I only receive these events:

[code]
r => 'EventLinkConnected' (95) attributes:
        AttributeApplicationName [str] = "pe_sipserverXXX"
        AttributeUserData [bstr] = KVList:
'host-0' [str] = "PESXXX"
'port-0' [int] = 3011
        AttributeRegistrationCode [int] = 0 [Primary]
        AttributeServerStartTime [long] = 6428912335205165912
        AttributeCustomerID [str] = "Resource"
        AttributeSessionID [int] = 7256825
        AttributeEventSequenceNumber [long] = 155496911
        TimeStamp:
                AttributeTimeinSecs [int] = 1499106074
                AttributeTimeinuSecs [int] = 767000
r => 'EventACK' (138) attributes:
        AttributeReferenceID [int] = 1
        AttributeCustomerID [str] = "Resource"
        AttributeUserEvent [int] = 7
        AttributeEventSequenceNumber [long] = 155496926
        TimeStamp:
                AttributeTimeinSecs [int] = 1499106074
                AttributeTimeinuSecs [int] = 829000


[/code]