Esempio n. 1
0
  void handleNewChannelEvent(NewChannelEvent event) {
    final AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId());

    if (channel == null) {
      if (event.getChannel() == null) {
        logger.info(
            "Ignored NewChannelEvent with empty channel name (uniqueId="
                + event.getUniqueId()
                + ")");
      } else {
        addNewChannel(
            event.getUniqueId(),
            event.getChannel(),
            event.getDateReceived(),
            event.getCallerIdNum(),
            event.getCallerIdName(),
            ChannelState.valueOf(event.getChannelState()),
            event.getAccountCode());
      }
    } else {
      // channel had already been created probably by a NewCallerIdEvent
      synchronized (channel) {
        channel.nameChanged(event.getDateReceived(), event.getChannel());
        channel.setCallerId(new CallerId(event.getCallerIdName(), event.getCallerIdNum()));
        channel.stateChanged(
            event.getDateReceived(), ChannelState.valueOf(event.getChannelState()));
      }
    }
  }
Esempio n. 2
0
    private void handleNewCall(
        String itemName, Class<? extends Item> itemType, NewChannelEvent event) {
      if (event.getCallerIdNum() == null || event.getExten() == null) {
        logger.debug("calleridnum or exten is null -> handle new call aborted!");
        return;
      }

      CallType call =
          new CallType(new StringType(event.getCallerIdNum()), new StringType(event.getExten()));
      eventCache.put(event.getUniqueId(), call);

      if (itemType.isAssignableFrom(SwitchItem.class)) {
        eventPublisher.postUpdate(itemName, OnOffType.ON);
      } else if (itemType.isAssignableFrom(CallItem.class)) {
        eventPublisher.postUpdate(itemName, call);
      } else {
        logger.warn("handle call for item type '{}' is undefined", itemName);
      }
    }