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


Java Message.getID方法代码示例

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


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

示例1: storeMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public static void storeMessage(final Message message) {
  LOGGER.debug("storeMessage : sender={}, receiver={}, messageId={}", new Object[]{message.getTo(), message.getFrom(), message.getID()});
  LOGGER.trace("storeMessage : message={}", message.toString().replaceAll("[\\r\\n]+", ""));
  String receiver = message.getTo().toFullJID();
  String messageId = message.getID();

  service.execute(new Runnable() {
    @Override
    public void run() {
      LOGGER.trace("storeMessage.run : addMessage from={}, to={}, messageId={}", new Object[]{message.getFrom(), message.getTo(), message.getID()});
      XMPPServer.getInstance().getOfflineMessageStore().addMessage(message);
    }
  });
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:15,代码来源:MMXOfflineStorageUtil.java

示例2: processIncoming

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
public void processIncoming(Packet packet) {
  if (packet instanceof Message) {
    LOGGER.debug("Sending the same message back");
    Message message = (Message) packet;
    Element mmx = message.getChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
    boolean receiptRequested = message.getChildElement(Constants.XMPP_REQUEST, Constants.XMPP_NS_RECEIPTS) != null;

    JID fromJID = message.getFrom();
    JID toJID = message.getTo();
    message.setTo(fromJID);

    Element internalMeta = mmx.element(Constants.MMX_MMXMETA);
    String userId = JIDUtil.getUserId(fromJID);
    String devId = fromJID.getResource();
    String mmxMetaJSON = MMXMetaBuilder.build(userId, devId);
    if (internalMeta != null) {
      mmx.remove(internalMeta);
    }

    Element revisedMeta = mmx.addElement(Constants.MMX_MMXMETA);
    revisedMeta.setText(mmxMetaJSON);

    if (receiptRequested) {
      //remove the receipt requested element to ensure we don't have a loop
      message.deleteExtension(Constants.XMPP_REQUEST, Constants.XMPP_NS_RECEIPTS);
    }
    try {
      //add a little sleep to differentiate between the send and recvd time.
      Thread.sleep(1000L);
    } catch (InterruptedException e) {
      e.printStackTrace();
    } finally {
    }
    autoRespondingConnection.sendPacket(message);
      /*
       * Acknowledge the receipt by sending an IQ
       */
    String originalMessageId = message.getID();
    String from = fromJID.toString();
    String to = toJID.toString();

    LOGGER.debug("Attempting to deliver ack");
    IQ ackIQ = buildAckIQ(from, to, originalMessageId);

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Ack IQ:{}", ackIQ.toXML());
    }
    autoRespondingConnection.sendPacket(ackIQ);

    if (receiptRequested) {
      LOGGER.debug("Sending delivery receipt for message with id:{}", originalMessageId);
      String appId = JIDUtil.getAppId(to);
      Message receipt = buildDeliveryReceipt(appId, from, to, originalMessageId);
      autoRespondingConnection.sendPacket(receipt);
    } else {
      LOGGER.debug("Not sending delivery receipt for message with id:{}", originalMessageId);
    }
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:61,代码来源:BotRegistrationImpl.java


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