/**
   * Called during initialization to populate the members of the queues.
   *
   * @param event the QueueMemberEvent received
   */
  private void handleQueueMemberEvent(QueueMemberEvent event) {
    final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue());
    if (queue == null) {
      logger.error("Ignored QueueEntryEvent for unknown queue " + event.getQueue());
      return;
    }

    AsteriskQueueMemberImpl member = queue.getMember(event.getLocation());
    if (member == null) {
      member =
          new AsteriskQueueMemberImpl(
              server,
              queue,
              event.getLocation(),
              QueueMemberState.valueOf(event.getStatus()),
              event.getPaused(),
              event.getPenalty(),
              event.getMembership(),
              event.getCallsTaken(),
              event.getLastCall());

      queue.addMember(member);
    } else {
      if (member.stateChanged(QueueMemberState.valueOf(event.getStatus()))
          | member.pausedChanged(event.getPaused())
          | member.penaltyChanged(event.getPenalty())
          | member.callsTakenChanged(event.getCallsTaken())
          | member.lastCallChanged(event.getLastCall())) {
        queue.stampLastUpdate();
      }
    }
  }
  /**
   * Challange a QueueMemberRemovedEvent.
   *
   * @param event - the generated QueueMemberRemovedEvent.
   */
  public void handleQueueMemberRemovedEvent(QueueMemberRemovedEvent event) {
    final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue());
    if (queue == null) {
      logger.error("Ignored QueueMemberRemovedEvent for unknown queue " + event.getQueue());
      return;
    }

    final AsteriskQueueMemberImpl member = queue.getMember(event.getLocation());
    if (member == null) {
      logger.error(
          "Ignored QueueMemberRemovedEvent for unknown agent name: "
              + event.getMemberName()
              + " location: "
              + event.getLocation()
              + " queue: "
              + event.getQueue());
      return;
    }

    queue.removeMember(member);
  }
  /**
   * Challange a QueueMemberAddedEvent.
   *
   * @param event - the generated QueueMemberAddedEvent.
   */
  public void handleQueueMemberAddedEvent(QueueMemberAddedEvent event) {
    final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue());
    if (queue == null) {
      logger.error("Ignored QueueMemberAddedEvent for unknown queue " + event.getQueue());
      return;
    }

    AsteriskQueueMemberImpl member = queue.getMember(event.getLocation());
    if (member == null) {
      member =
          new AsteriskQueueMemberImpl(
              server,
              queue,
              event.getLocation(),
              QueueMemberState.valueOf(event.getStatus()),
              event.getPaused(),
              event.getPenalty(),
              event.getMembership(),
              event.getCallsTaken(),
              event.getLastCall());
    }

    queue.addMember(member);
  }