当前位置: 首页>>代码示例>>Java>>正文


Java Message.getExtension方法代码示例

本文整理汇总了Java中org.xmpp.packet.Message.getExtension方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getExtension方法的具体用法?Java Message.getExtension怎么用?Java Message.getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmpp.packet.Message的用法示例。


在下文中一共展示了Message.getExtension方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Build a DeliveryConfirmationMessage using the source Message
 * @param source
 * @return DeliveryConfirmationMessage if the source message represents a DeliveryConfirmation
 * null other wise.
 */
public static DeliveryConfirmationMessage build (Message source) {
  DeliveryConfirmationMessage dc = null;
  if (source != null) {
    PacketExtension confirmation = source.getExtension(Constants.XMPP_RECEIVED, Constants.XMPP_NS_RECEIPTS);
    if (confirmation != null) {
      //make sure we have the id attribute which identifies the id of the message
      //for which this message represents a delivery confirmation
      Element extensionElement = confirmation.getElement();
      String idVal = extensionElement.attributeValue(Constants.XMPP_ATTR_ID);
      if (idVal != null || !idVal.isEmpty()) {
        dc = new DeliveryConfirmationMessage();
        dc.messageId = idVal;
        dc.wrapped = source;

        JID from = source.getFrom();
        if (from != null && from.getResource() != null) {
          dc.confirmingDeviceId = from.getResource();
        }
      }
    }
  }
  return dc;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:30,代码来源:DeliveryConfirmationMessage.java

示例2: isPubSubMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public static boolean isPubSubMessage(Message message) {
  if (message == null) {
    return false;
  }
  final String namespace = "http://jabber.org/protocol/pubsub#event";
  final String event = "event";
  final String items = "items";

  PacketExtension extension = message.getExtension(event, namespace);
  if (extension != null) {
    Element eventElement = extension.getElement();
    if (eventElement != null) {
      Element itemElement = eventElement.element(items);
      if (itemElement != null) {
        return true;
      }
    }
  } else {
    return false;
  }
  return false;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:23,代码来源:MMXMessageUtil.java

示例3: process

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Handles Message packets sent to the pubsub service. Messages may be of type error
 * when an event notification was sent to a susbcriber whose address is no longer available.<p>
 *
 * Answers to authorization requests sent to node owners to approve pending subscriptions
 * will also be processed by this method.
 *
 * @param service the PubSub service this action is to be performed for.
 * @param message the Message packet sent to the pubsub service.
 */
public void process(PubSubService service, Message message) {
    if (message.getType() == Message.Type.error) {
        // Process Messages of type error to identify possible subscribers that no longer exist
        if (message.getError().getType() == PacketError.Type.cancel) {
            // TODO Assuming that owner is the bare JID (as defined in the JEP). This can be replaced with an explicit owner specified in the packet
            JID owner = message.getFrom().asBareJID();
            // Terminate the subscription of the entity to all nodes hosted at the service
           cancelAllSubscriptions(service, owner);
        }
        else if (message.getError().getType() == PacketError.Type.auth) {
            // TODO Queue the message to be sent again later (will retry a few times and
            // will be discarded when the retry limit is reached)
        }
    }
    else if (message.getType() == Message.Type.normal) {
        // Check that this is an answer to an authorization request
        DataForm authForm = (DataForm) message.getExtension("x", "jabber:x:data");
        if (authForm != null && authForm.getType() == DataForm.Type.submit) {
            String formType = authForm.getField("FORM_TYPE").getValues().get(0);
            // Check that completed data form belongs to an authorization request
            if ("http://jabber.org/protocol/pubsub#subscribe_authorization".equals(formType)) {
                // Process the answer to the authorization request
                processAuthorizationAnswer(service, authForm, message);
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:38,代码来源:PubSubEngine.java

示例4: process

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Handles Message packets sent to the pubsub service. Messages may be of type error
 * when an event notification was sent to a susbcriber whose address is no longer available.<p>
 *
 * Answers to authorization requests sent to node owners to approve pending subscriptions
 * will also be processed by this method.
 *
 * @param service the PubSub service this action is to be performed for.
 * @param message the Message packet sent to the pubsub service.
 */
public void process(PubSubService service, Message message) {
    if (message.getType() == Message.Type.error) {
        // Process Messages of type error to identify possible subscribers that no longer exist
        if (message.getError().getType() == PacketError.Type.cancel) {
            // TODO Assuming that owner is the bare JID (as defined in the JEP). This can be replaced with an explicit owner specified in the packet
            JID owner = new JID(message.getFrom().toBareJID());
            // Terminate the subscription of the entity to all nodes hosted at the service
           cancelAllSubscriptions(service, owner);
        }
        else if (message.getError().getType() == PacketError.Type.auth) {
            // TODO Queue the message to be sent again later (will retry a few times and
            // will be discarded when the retry limit is reached)
        }
    }
    else if (message.getType() == Message.Type.normal) {
        // Check that this is an answer to an authorization request
        DataForm authForm = (DataForm) message.getExtension("x", "jabber:x:data");
        if (authForm != null && authForm.getType() == DataForm.Type.submit) {
            String formType = authForm.getField("FORM_TYPE").getValues().get(0);
            // Check that completed data form belongs to an authorization request
            if ("http://jabber.org/protocol/pubsub#subscribe_authorization".equals(formType)) {
                // Process the answer to the authorization request
                processAuthorizationAnswer(service, authForm, message);
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:38,代码来源:PubSubEngine.java

示例5: handleMMXMulticast

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void handleMMXMulticast(MMXMsgRuleInput input)
    throws PacketRejectedException {
  Message message = input.getMessage();
  JID mcastJid = message.getTo();
  String appId = JIDUtil.getAppId(mcastJid);
  PacketExtension payload = message.getExtension(Constants.MMX,
      Constants.MMX_NS_MSG_PAYLOAD);
  if (payload == null) {
    LOGGER.warn("Dropping a malformed MMX multicast message.");
    if (!(Boolean) getMmxMeta(payload, MmxHeaders.NO_ACK, Boolean.FALSE)) {
      sendBeginAckMessageOnce(message, appId, 0, ErrorCode.SEND_MESSAGE_MALFORMED);
    }
    throw new PacketRejectedException(
        "Stop processing for malformed multicast message");
  }

  MMXid[] recipients = getRecipients(payload);
  if (recipients == null || recipients.length == 0) {
    LOGGER.warn("No recipients found in MMX multicast message");
    if (!(Boolean) getMmxMeta(payload, MmxHeaders.NO_ACK, Boolean.FALSE)) {
      sendBeginAckMessageOnce(message, appId, 0, ErrorCode.SEND_MESSAGE_NO_TARGET);
    }
  } else {
    // Save a recipient counter for the multicast message and send a begin
    // ack. The count will be decremented when each routed message is handled
    // later.  When the count reaches zero, the end ack will be sent.  Note,
    // the packet routing in the for-loop is done asynchronously.
    if (!(Boolean) getMmxMeta(payload, MmxHeaders.NO_ACK, Boolean.FALSE)) {
      sendBeginAckMessageOnce(message, appId, recipients.length, ErrorCode.NO_ERROR);
    }

    PacketRouter pktRouter = XMPPServer.getInstance().getPacketRouter();
    for (MMXid recipient : recipients) {
      JID jid = new JID(JIDUtil.makeNode(recipient.getUserId(), appId),
          mcastJid.getDomain(), recipient.getDeviceId(), true);
      // TODO: need a deep copy because payload cannot be shared with
      // multiple messages; it has a DOM parent.
      Message unicastMsg = message.createCopy();
      unicastMsg.setTo(jid);
      pktRouter.route(unicastMsg);
    }
  }
  throw new PacketRejectedException("MMX multicast message is processed");
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:45,代码来源:MMXMessageHandlingRule.java

示例6: handleBareJID

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void handleBareJID(Message message) {
  if (message.getTo().getNode() == null) {
    LOGGER.trace("handleBareJID: ignoring a multicast message={}", message);
    // It is a multicast message (XEP-0033); let MulticastRouter handle it.
    return;
  }
  // annotate the message to indicate that we have distributed it.
  MessageAnnotator annotator = new MessageDistributedAnnotator();
  annotator.annotate(message);
  LOGGER.trace("handleBareJID : message={}", message);
  MessageEntity messageEntity = MMXMessageHandlingRule
      .getMessageEntity(message);
  String domain = message.getTo().getDomain();
  String userId = JIDUtil.getUserId(message.getTo());
  MessageDistributor distributor = new MessageDistributorImpl();
  MessageDistributor.DistributionContext context = new DistributionContextImpl(
      userId, messageEntity.getAppId(), domain, messageEntity.getMessageId());
  MessageDistributor.DistributionResult result = distributor.distribute(
      message, context);
  AppDAO appDAO = DBUtil.getAppDAO();
  AppEntity appEntity = appDAO.getAppForAppKey(messageEntity.getAppId());
  List<MessageDistributor.JIDDevicePair> undistributed = result
      .getNotDistributed();
  for (MessageDistributor.JIDDevicePair pair : undistributed) {
    message.setTo(pair.getJID());
    MMXOfflineStorageUtil.storeMessage(message);
    messageEntity.setTo(message.getTo().toString());
    messageEntity.setDeviceId(pair.getJID().getResource());
    boolean wokenUpPossible = canBeWokenUp(pair.getDevice());
    if (wokenUpPossible) {
      messageEntity.setState(MessageEntity.MessageState.WAKEUP_REQUIRED);
      WakeupUtil.queueWakeup(appEntity, pair.getDevice(),
          messageEntity.getMessageId());
    } else {
      messageEntity.setState(MessageEntity.MessageState.PENDING);
    }
    DBUtil.getMessageDAO().persist(messageEntity);
  }

  if (result.noDevices()) {
    LOGGER.warn(
            "message={} addressed to user={} is dropped because the user has no active devices. Sending an error message back to originator.",
            message, userId);
  }

  PacketExtension payload = message.getExtension(Constants.MMX,
      Constants.MMX_NS_MSG_PAYLOAD);
  if (payload == null || !(Boolean) getMmxMeta(payload, MmxHeaders.NO_ACK,
      Boolean.FALSE)) {
    if (isMMXMulticastMessage(message)) {
      // Send end-ack for the last recipient in the multicast message.
      sendEndAckMessageOnce(message, appEntity.getAppId(), result.noDevices());
    } else {
      // Send ack or nack for the unicast message.
      sendServerAckMessage(message, appEntity.getAppId(), result.noDevices());
    }
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:59,代码来源:MMXMessageHandlingRule.java

示例7: isMulticastMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private static boolean isMulticastMessage(Message message) {
  // XEP-0033 multi-recipients message.
  final String addresses = "addresses";
  final String namespace = "http://jabber.org/protocol/address";
  return (message.getExtension(addresses, namespace) != null);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:7,代码来源:MMXMessageUtil.java

示例8: isGeoEventMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private static boolean isGeoEventMessage(Message message) {
  return message.getExtension(Constants.MMX_ELEMENT, Constants.MMX_NS_CONTEXT) != null;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:4,代码来源:MMXMessageUtil.java

示例9: isConfirmationMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public static boolean isConfirmationMessage(Message message) {
  return message.getExtension(Constants.XMPP_RECEIVED, Constants.XMPP_NS_RECEIPTS) != null;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:4,代码来源:MMXMessageUtil.java


注:本文中的org.xmpp.packet.Message.getExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。