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

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

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

Message.setStanzaId介绍

暂无

代码示例

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

private static Message getNewMessage() {
    Message message = new Message();
    message.setStanzaId(null);
    return message;
  }
}

代码示例来源: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

@Test
public void messageTest() {
  Message message = new Message(JidTestUtil.BARE_JID_1, Message.Type.headline);
  message.setStanzaId("message-id");
  String string = message.toString();
  assertEquals("Message Stanza [to=one@exampleone.org,id=message-id,type=headline,]", string);
}

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

@Test
public void setMessageTypeTest() throws IOException, SAXException {
  Message.Type type = Message.Type.chat;
  Message.Type type2 = Message.Type.headline;
  StringBuilder controlBuilder = new StringBuilder();
  controlBuilder.append("<message")
      .append(" type=\"")
      .append(type)
      .append("\">")
      .append("</message>");
  String control = controlBuilder.toString();
  Message messageTypeInConstructor = new Message(null, Message.Type.chat);
  messageTypeInConstructor.setStanzaId(null);
  assertEquals(type, messageTypeInConstructor.getType());
  assertXMLEqual(control, messageTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
  controlBuilder = new StringBuilder();
  controlBuilder.append("<message")
      .append(" type=\"")
      .append(type2)
      .append("\">")
      .append("</message>");
  control = controlBuilder.toString();
  Message messageTypeSet = getNewMessage();
  messageTypeSet.setType(type2);
  assertEquals(type2, messageTypeSet.getType());
  assertXMLEqual(control, messageTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}

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

message.setStanzaId(parser.getAttributeValue("", "id"));
message.setTo(ParserUtils.getJidAttribute(parser, "to"));
message.setFrom(ParserUtils.getJidAttribute(parser, "from"));

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

@Test
public void checkReceivedExtension() throws Exception {
  Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
  message.setStanzaId("message-2");
  message.addExtension(new ChatMarkersElements.ReceivedExtension("message-1"));
  Assert.assertEquals(receivedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}

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

@Test
public void checkDisplayedExtension() throws Exception {
  Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
  message.setStanzaId("message-2");
  message.addExtension(new ChatMarkersElements.AcknowledgedExtension("message-1"));
  Assert.assertEquals(acknowledgedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}

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

@Test
public void checkMarkableExtension() throws Exception {
  Message message = new Message(JidCreate.from("ingrichard@royalty.england.lit/throne"));
  message.setStanzaId("message-1");
  message.setBody("My lord, dispatch; read o'er these articles.");
  message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
  Assert.assertEquals(markableMessageStanza, message.toXML(null).toString());
}

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

@Test
public void checkDisplayedExtension() throws Exception {
  Message message = new Message(JidCreate.from("northumberland@shakespeare.lit/westminster"));
  message.setStanzaId("message-2");
  message.addExtension(new ChatMarkersElements.DisplayedExtension("message-1"));
  Assert.assertEquals(displayedMessageStanza, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}

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

String messageId = message.setStanzaId();
final String messageBody = "Test MAM message (" + testRunId + ')';
message.setBody(messageBody);

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

@Test
public void receiptManagerListenerTest() throws Exception {
  DummyConnection c = new DummyConnection();
  c.connect();
  DeliveryReceiptManager drm = DeliveryReceiptManager.getInstanceFor(c);
  TestReceiptReceivedListener rrl = new TestReceiptReceivedListener();
  drm.addReceiptReceivedListener(rrl);
  Message m = new Message(JidCreate.from("romeo@montague.com"), Message.Type.normal);
  m.setFrom(JidCreate.from("julia@capulet.com"));
  m.setStanzaId("reply-id");
  m.addExtension(new DeliveryReceipt("original-test-id"));
  c.processStanza(m);
  rrl.waitUntilInvocationOrTimeout();
}

代码示例来源: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: igniterealtime/Smack

@Test
  public void receiptManagerAutoReplyTest() throws Exception {
    DummyConnection c = new DummyConnection();
    c.connect();
    DeliveryReceiptManager drm = DeliveryReceiptManager.getInstanceFor(c);

    drm.setAutoReceiptMode(AutoReceiptMode.always);
    assertEquals(AutoReceiptMode.always, drm.getAutoReceiptMode());

    // test auto-receipts
    Message m = new Message(JidCreate.from("julia@capulet.com"), Message.Type.normal);
    m.setFrom(JidCreate.from("romeo@montague.com"));
    m.setStanzaId("test-receipt-request");
    DeliveryReceiptRequest.addTo(m);

    // the DRM will send a reply-packet
    c.processStanza(m);

    Stanza reply = c.getSentPacket();
    DeliveryReceipt r = DeliveryReceipt.from((Message) reply);
    assertThat("romeo@montague.com", equalsCharSequence(reply.getTo()));
    assertEquals("test-receipt-request", r.getId());
  }
}

代码示例来源:origin: org.igniterealtime.smack/smack-core

message.setStanzaId(parser.getAttributeValue("", "id"));
message.setTo(ParserUtils.getJidAttribute(parser, "to"));
message.setFrom(ParserUtils.getJidAttribute(parser, "from"));

相关文章