Example #1
0
  void initialize() throws ManagerCommunicationException {
    ResponseEvents re;

    try {
      re = server.sendEventGeneratingAction(new QueueStatusAction());
    } catch (ManagerCommunicationException e) {
      final Throwable cause = e.getCause();

      if (cause instanceof EventTimeoutException) {
        // this happens with Asterisk 1.0.x as it doesn't send a
        // QueueStatusCompleteEvent
        re = ((EventTimeoutException) cause).getPartialResult();
      } else {
        throw e;
      }
    }

    for (ManagerEvent event : re.getEvents()) {
      if (event instanceof QueueParamsEvent) {
        handleQueueParamsEvent((QueueParamsEvent) event);
      } else if (event instanceof QueueMemberEvent) {
        handleQueueMemberEvent((QueueMemberEvent) event);
      } else if (event instanceof QueueEntryEvent) {
        handleQueueEntryEvent((QueueEntryEvent) event);
      }
    }
  }
Example #2
0
  /**
   * Method to ask for a Queue data update
   *
   * @author Octavio Luna
   * @param queue
   * @throws ManagerCommunicationException
   */
  void updateQueue(String queue) throws ManagerCommunicationException {
    ResponseEvents re;

    try {
      QueueStatusAction queueStatusAction = new QueueStatusAction();
      queueStatusAction.setQueue(queue);
      re = server.sendEventGeneratingAction(queueStatusAction);
    } catch (ManagerCommunicationException e) {
      final Throwable cause = e.getCause();

      if (cause instanceof EventTimeoutException) {
        // this happens with Asterisk 1.0.x as it doesn't send a
        // QueueStatusCompleteEvent
        re = ((EventTimeoutException) cause).getPartialResult();
      } else {
        throw e;
      }
    }

    for (ManagerEvent event : re.getEvents()) {
      // 101119 OLB: solo actualizamos el QUEUE por ahora
      if (event instanceof QueueParamsEvent) {
        handleQueueParamsEvent((QueueParamsEvent) event);
      } else if (event instanceof QueueMemberEvent) {
        handleQueueMemberEvent((QueueMemberEvent) event);
      } else if (event instanceof QueueEntryEvent) {
        handleQueueEntryEvent((QueueEntryEvent) event);
      }
    }
  }