org.jivesoftware.smack.packet.Message.getStanzaId()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.jivesoftware.smack.packet.Message.getStanzaId()方法的一些代码示例,展示了Message.getStanzaId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getStanzaId()方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:getStanzaId

Message.getStanzaId介绍

暂无

代码示例

代码示例来源:origin: igniterealtime/Smack

/**
 * Add a delivery receipt request to an outgoing packet.
 *
 * Only message packets may contain receipt requests as of XEP-0184,
 * therefore only allow Message as the parameter type.
 *
 * @param message Message object to add a request to
 * @return the Message ID which will be used as receipt ID
 */
public static String addTo(Message message) {
  if (message.getStanzaId() == null) {
    message.setStanzaId(StanzaIdUtil.newStanzaId());
  }
  message.addExtension(new DeliveryReceiptRequest());
  return message.getStanzaId();
}

代码示例来源:origin: igniterealtime/Smack

@Override
  public void processStanza(Stanza packet) {
    Message message = (Message) packet;
    MessageEvent messageEvent = message.getExtension("x", "jabber:x:event");
    if (messageEvent.isMessageEventRequest()) {
      // Fire event for requests of message events
      for (String eventType : messageEvent.getEventTypes())
        fireMessageEventRequestListeners(
          message.getFrom(),
          message.getStanzaId(),
          eventType.concat("NotificationRequested"));
    } else
      // Fire event for notifications of message events
      for (String eventType : messageEvent.getEventTypes())
        fireMessageEventNotificationListeners(
          message.getFrom(),
          messageEvent.getStanzaId(),
          eventType.concat("Notification"));
  }
}, PACKET_FILTER);

代码示例来源:origin: igniterealtime/Smack

/**
   * Create and return a new message including a delivery receipt extension for the given message.
   * <p>
   * If {@code messageWithReceiptRequest} does not have a Stanza ID set, then {@code null} will be returned.
   * </p>
   *
   * @param messageWithReceiptRequest the given message with a receipt request extension.
   * @return a new message with a receipt or <code>null</code>.
   * @since 4.1
   */
  public static Message receiptMessageFor(Message messageWithReceiptRequest) {
    String stanzaId = messageWithReceiptRequest.getStanzaId();
    if (StringUtils.isNullOrEmpty(stanzaId)) {
      return null;
    }
    Message message = new Message(messageWithReceiptRequest.getFrom(), messageWithReceiptRequest.getType());
    message.addExtension(new DeliveryReceipt(stanzaId));
    return message;
  }
}

代码示例来源:origin: igniterealtime/Smack

assertEquals(messageId, mamMessage.getStanzaId());
assertEquals(messageBody, mamMessage.getBody());
assertEquals(conOne.getUser(), mamMessage.getFrom());

代码示例来源:origin: igniterealtime/Smack

@Test
public void checkMamQueryResults() throws Exception {
  Message message = new Message();
  message.setStanzaId("iasd207");
  message.setFrom(JidCreate.from("coven@chat.shakespeare.lit"));
  message.setTo(JidCreate.from("hag66@shakespeare.lit/pda"));
  GregorianCalendar calendar = new GregorianCalendar(2002, 10 - 1, 13, 23, 58, 37);
  calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
  Date date = calendar.getTime();
  DelayInformation delay = new DelayInformation(date);
  Message forwardedMessage = new Message();
  forwardedMessage.setFrom(JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
  forwardedMessage.setStanzaId("162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
  forwardedMessage.setType(Type.chat);
  forwardedMessage.setBody("Thrice the brinded cat hath mew.");
  Forwarded forwarded = new Forwarded(delay, forwardedMessage);
  message.addExtension(new MamResultExtension("g27", "34482-21985-73620", forwarded));
  // FIXME: The order of assertEquals is reversed, fix it by switching it.
  Assert.assertEquals(message.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), mamQueryResultExample);
  MamResultExtension mamResultExtension = MamResultExtension.from(message);
  Assert.assertEquals(mamResultExtension.getId(), "34482-21985-73620");
  Assert.assertEquals(mamResultExtension.getForwarded().getDelayInformation().getStamp(), date);
  Message resultMessage = (Message) mamResultExtension.getForwarded().getForwardedStanza();
  Assert.assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
  Assert.assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
  Assert.assertEquals(resultMessage.getType(), Type.chat);
  Assert.assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
}

代码示例来源:origin: spring-projects/spring-integration

assertEquals(smackMessage.getStanzaId(), ((Message) payload).getStanzaId());
assertEquals(smackMessage.getBody(), ((Message) payload).getBody());

代码示例来源:origin: igniterealtime/Spark

public void insertMessage(Message message) {
  // Debug info
  super.insertMessage(message);
  MessageEvent messageEvent = message.getExtension("x", "jabber:x:event");
  if (messageEvent != null) {
    checkEvents(message.getFrom(), message.getStanzaId(), messageEvent);
  }
  getTranscriptWindow().insertMessage(participantNickname, message, ChatManager.FROM_COLOR);
  // Set the participant jid to their full JID.
  setparticipantJID(message.getFrom());
}

代码示例来源:origin: igniterealtime/Spark

SparkManager.getMessageEventManager().sendDeliveredNotification(message.getFrom(), message.getStanzaId());
SparkManager.getMessageEventManager().sendDisplayedNotification(message.getFrom(), message.getStanzaId());

代码示例来源:origin: igniterealtime/Spark

message.setType( Message.Type.groupchat );
MessageEventManager.addNotificationsRequests( message, true, true, true, true );
addPacketID( message.getStanzaId() );

相关文章