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


Java Message.createCopy方法代码示例

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


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

示例1: bounce

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void bounce(Message message) {
    // Do nothing if the sender was the server itself
    if (message.getFrom() == null || message.getFrom().equals( serverAddress )) {
        return;
    }
    try {
        // Generate a rejection response to the sender
        Message errorResponse = message.createCopy();
        // return an error stanza to the sender, which SHOULD be <service-unavailable/>
        errorResponse.setError(PacketError.Condition.service_unavailable);
        errorResponse.setFrom(message.getTo());
        errorResponse.setTo(message.getFrom());
        // Send the response
        router.route(errorResponse);
        // Inform listeners that an offline message was bounced
        if (!listeners.isEmpty()) {
            for (OfflineMessageListener listener : listeners) {
                listener.messageBounced(message);
            }
        }
    }
    catch (Exception e) {
        Log.error(e.getMessage(), e);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:26,代码来源:OfflineMessageStrategy.java

示例2: bounce

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void bounce(Message message) {
    // Do nothing if the sender was the server itself
    if (message.getFrom() == null) {
        return;
    }
    try {
        // Generate a rejection response to the sender
        Message errorResponse = message.createCopy();
        errorResponse.setError(new PacketError(PacketError.Condition.item_not_found,
                PacketError.Type.continue_processing));
        errorResponse.setFrom(message.getTo());
        errorResponse.setTo(message.getFrom());
        // Send the response
        router.route(errorResponse);
        // Inform listeners that an offline message was bounced
        if (!listeners.isEmpty()) {
            for (OfflineMessageListener listener : listeners) {
                listener.messageBounced(message);
            }
        }
    }
    catch (Exception e) {
        Log.error(e.getMessage(), e);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:26,代码来源:OfflineMessageStrategy.java

示例3: distribute

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
public DistributionResult distribute(Message message, DistributionContext context) {
  DeviceDAO deviceDAO = getDeviceDAO();
  String bareUserId = context.getBareUserId();
  String appKey = context.getAppId();
  String domain = context.getServerHostname();
  List<DeviceEntity> devices = deviceDAO.getDevices(appKey, bareUserId, DeviceStatus.ACTIVE);
  LOGGER.info("distribute : Distributing messages for user={}, messageId={}, numDevices={} ", new Object[]{context.getBareUserId(), context.getMessageId(), devices.size()});

  List<JID> distributed = new ArrayList<JID>();
  List<JIDDevicePair> undistributed = new ArrayList<JIDDevicePair>();
  boolean noDevices = (devices.size() == 0);
  for (DeviceEntity entity : devices) {
    String deviceId = entity.getDeviceId();
    Message cloned = message.createCopy();
    JID deviceSpecificJID = buildToAddress(bareUserId, appKey, domain, deviceId);
    cloned.setTo(deviceSpecificJID);
    MMXPresenceFinder finder = getPresenceFinder();
    if(finder.isOnline(deviceSpecificJID)) {
     LOGGER.trace("distribute : found online deviceSpecificJID={}", deviceSpecificJID);
     route(cloned);
     distributed.add(deviceSpecificJID);
    } else {
      LOGGER.trace("distribute : not found online deviceSpecificJID={}", deviceSpecificJID);
      JIDDevicePairImpl pair = new JIDDevicePairImpl(deviceSpecificJID, entity);
      undistributed.add(pair);
    }
  }
  return new DistributionResultImpl(distributed, undistributed, noDevices);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:31,代码来源:MessageDistributorImpl.java

示例4: 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

示例5: Forwarded

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public Forwarded(Message message, Date delay, JID delayFrom) {
    super("forwarded", "urn:xmpp:forward:0");

    Message copy = message.createCopy();
    populate(copy.getElement(), delay, delayFrom);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:7,代码来源:Forwarded.java

示例6: storeOffline

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void storeOffline(Message message) {
    if (message != null) {
        // Do nothing if the message was sent to the server itself, an anonymous user or a non-existent user
        JID recipientJID = message.getTo();
        if (recipientJID == null || serverAddress.equals(recipientJID) ||
                recipientJID.getNode() == null ||
                !UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
            return;
        }
        // Do not store messages of type groupchat, error or headline as specified in JEP-160
        if (Message.Type.groupchat == message.getType() ||
                Message.Type.error == message.getType() ||
                Message.Type.headline == message.getType()) {
            return;
        }
        // Do not store messages if communication is blocked
        PrivacyList list =
                PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
        if (list != null && list.shouldBlockPacket(message)) {
            Message result = message.createCopy();
            result.setTo(message.getFrom());
            result.setError(PacketError.Condition.service_unavailable);
            XMPPServer.getInstance().getRoutingTable().routePacket(message.getFrom(), result, true);
            return;
        }

        if (type == Type.bounce) {
            bounce(message);
        }
        else if (type == Type.store) {
            store(message);
        }
        else if (type == Type.store_and_bounce) {
            if (underQuota(message)) {
                store(message);
            }
            else {
                bounce(message);
            }
        }
        else if (type == Type.store_and_drop) {
            if (underQuota(message)) {
                store(message);
            }
        }
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:48,代码来源:OfflineMessageStrategy.java


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