Author Topic: Is it possible to filter call events by parameters or data in specific?  (Read 3068 times)

Offline apu321X

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
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]


« Last Edit: June 30, 2017, 11:49:05 PM by apu321X »

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
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.

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
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]

Offline apu321X

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
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]

« Last Edit: July 03, 2017, 06:44:46 PM by apu321X »